본문 바로가기

kubernetes

helm install bitnami/postgresql 및 id/pw는 뭐여

 

0단계 - 설명좀 해줘~~배경을~~서론

  • bitnami/postgressql 을 helm으로 설치했다. 
  • 그런디, id / pw 는 뭐여?

1단계 - helm install 할때 알려준다

[root@vmaster ~]# helm install my-postgres bitnami/postgresql
NAME: my-release
LAST DEPLOYED: Thu Mar 17 05:05:40 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: postgresql
CHART VERSION: 11.1.8
APP VERSION: 14.2.0

** Please be patient while the chart is being deployed **

PostgreSQL can be accessed via port 5432 on the following DNS names from within your cluster:

    my-release-postgresql.default.svc.cluster.local - Read/Write connection

To get the password for "postgres" run:

    export POSTGRES_PASSWORD=$(kubectl get secret --namespace default my-postgres-postgresql -o jsonpath="{.data.postgres-password}" | base64 --decode)

To connect to your database run the following command:

    kubectl run my-release-postgresql-client --rm --tty -i --restart='Never' --namespace default --image docker.io/bitnami/postgresql:14.2.0-debian-10-r33 --env="PGPASSWORD=$POSTGRES_PASSWORD" \
      --command -- psql --host my-postgres-postgresql -U postgres -d postgres -p 5432

    > NOTE: If you access the container using bash, make sure that you execute "/opt/bitnami/scripts/entrypoint.sh /bin/bash" in order to avoid the error "psql: local user with ID 1001} does not exist"

To connect to your database from outside the cluster execute the following commands:

    kubectl port-forward --namespace default svc/my-postgres-postgresql 5432:5432 &
    PGPASSWORD="$POSTGRES_PASSWORD" psql --host 127.0.0.1 -U postgres -d postgres -p 5432
  • 저기 보이십니까? 다음 명령을 실행시키면 패스워드를 알 수 있다고 합니다 . ;;;;이런.;;;
    • 저는 메시지를 무시해서 이런 생 삽질을 했네요. 구글링해도 패스워드는 알려주지 않았습니다 .
To get the password for "postgres" run:

    export POSTGRES_PASSWORD=$(kubectl get secret --namespace default my-postgres-postgresql -o jsonpath="{.data.postgres-password}" | base64 --decode)

 

  •  다음과 같이 확인경수를 확인하면 됩니다.
[root@vmaster ~]# echo $POSTGRES_PASSWORD
뭐시기뭐시기

 

2단계 - psql로 접속해본다

  • 1단계에서 알아낸 password로 접속해본다.
  • bitnami/postgresql pod의 bash를 실행시킨다~! 그리고 
  • psql을 실행시켜 접속한다. 
    • user id 도 위 메시지에서 알려주고 있다. (제발 메시지 좀 신중하게 읽자!!!)
    • user id : "postgres"
[root@vmaster ~]# kubectl exec -it my-postgres-postgresql-0 bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.

I have no name!@my-release-postgresql-0:/$ pqsl -U postgres
bash: pqsl: command not found
I have no name!@my-release-postgresql-0:/$ psql -U postgres
Password for user postgres:
psql (14.2)
Type "help" for help.

postgres=#

 

3단계 - 결론!

  • 설치할 때 알려준다.
    • 제발 메시지 좀 읽자!!!!!!!!!!!!!!!!!!!!!!-->  저에게 하는 스스로 잔소리!!!^^;;;

4단계 - 추가 : 쉬운 패스워드로 바꾸고 싶다

ALTER USER user_name WITH PASSWORD 'new_password';
  • psql 을 실행시키고 위 명령을 실행시키면 된다.
    • bitnami가 알려준 랜덤한 패스워드는 외울 수 가 없다...;;;;ㅜ,.ㅜ