我已经根据timescaledb
我的安装位置创建了一个自定义映像,wal2json
并且我正在尝试使用 crunchydata-postgres-operator 将它部署在我的 kubernetes 集群上。除了访问数据库的凭据之外,我已经设法设置了所有内容。
我正在尝试使用以下命令创建 pgo 集群:
pgo create cluster my-db --ccp-image-prefix="eu.gcr.io/<project-id>" --ccp-image="timescale-custom" -c latest -d <dbname> -u <username> --password="<my_password>"
该命令执行成功,但是数据库部署进入a CrashLoopBackOff
,因为如下错误:
Error: Database is uninitialized and superuser password is not specified.
You must specify POSTGRES_PASSWORD to a non-empty value for the
superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".
You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
connections without a password. This is *not* recommended.
See PostgreSQL documentation about "trust":
https://www.postgresql.org/docs/current/auth-trust.html
看到这个我尝试在Dockerfile中设置POSTGRES_PASSWORD
and POSTGRES_USER
,但这并不能缓解问题?
我知道通常这些环境变量是在 k8sdeployment.yaml
或者docker-compose.yml
. 但是即使 postgres 操作员有一些默认凭据,它们似乎也没有应用于容器?
Dockerfile:
FROM postgres:12 AS build
ENV VERSION 1_0
RUN buildDeps="curl build-essential ca-certificates git pkg-config glib2.0 postgresql-server-dev-$PG_MAJOR" \
&& apt-get update \
&& apt-get install -y --no-install-recommends ${buildDeps} \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& apt-get update \
&& apt-get install -y --no-install-recommends libc++1 postgresql-server-dev-$PG_MAJOR \
&& mkdir -p /tmp/build \
&& curl -o /tmp/build/${VERSIONN}.tar.gz -SL "https://github.com/eulerto/wal2json/archive/wal2json_${VERSION}.tar.gz" \
&& cd /tmp/build/ \
&& tar -xzf /tmp/build/${VERSIONN}.tar.gz -C /tmp/build/ \
&& cd /tmp/build/wal2json-wal2json_${VERSION} \
&& make && make install \
&& mkdir /outputs \
&& cp wal2json.so /outputs/ \
&& cd / \
&& rm -rf /tmp/build \
&& apt-get remove -y --purge ${buildDeps} \
&& apt-get autoremove -y --purge \
&& rm -rf /var/lib/apt/lists/
FROM timescale/timescaledb:1.7.4-pg12
COPY --from=build /outputs/wal2json.so /usr/local/lib/postgresql/
RUN echo "host replication all 127.0.0.1/32 trust" >> /var/lib/postgresql/data/pg_hba.conf
ENV POSTGRES_USER=<username> POSTGRES_PASSWORD=<password>
编辑:
使用标志运行相同的命令后,--debug
我收到了以下输出:
DEBU[0000] debug flag is set to true
DEBU[0000] in initConfig with url=https://127.0.0.1:8443
DEBU[0000] using PGO_NAMESPACE env var pgo
DEBU[0000] GetSessionCredentials called
DEBU[0000] PGOUSER environment variable is being used at /home/mycloud/.pgo/pgo/pgouser
DEBU[0000] pgouser file found at /home/mycloud/.pgo/pgo/pgouser contains admin:examplepassword
DEBU[0000] [admin examplepassword]
DEBU[0000] username=[admin] password=[examplepassword]
DEBU[0000] setting up httpclient with TLS
DEBU[0000] GetTLSTransport called
DEBU[0000] create cluster called
DEBU[0000] IsValidForResourceName: my-db
DEBU[0000] createCluster called...[https://127.0.0.1:8443/clusters]
DEBU[0000] &{200 OK 200 HTTP/1.1 1 1 map[Content-Length:[193] Content-Type:[application/json] Date:[Sat, 09 Jan 2021 19:56:05 GMT] Www-Authenticate:[Basic realm="Restricted"]] 0xc00017c080 193 [] false false map[]