You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

NOTES.txt 2.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. MySQL can be accessed via port 3306 on the following DNS name from within your cluster:
  2. {{ template "mysql.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local
  3. {{- if .Values.mysqlx.port.enabled }}
  4. Connection to the X protocol of MySQL can be done via 33060 on the following DNS name from within your cluster:
  5. {{ template "mysql.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local
  6. {{- end }}
  7. {{- if .Values.existingSecret }}
  8. If you have not already created the mysql password secret:
  9. kubectl create secret generic {{ .Values.existingSecret }} --namespace {{ .Release.Namespace }} --from-file=./mysql-root-password --from-file=./mysql-password
  10. {{ else }}
  11. To get your root password run:
  12. MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "mysql.fullname" . }} -o jsonpath="{.data.mysql-root-password}" | base64 --decode; echo)
  13. {{- end }}
  14. To connect to your database:
  15. 1. Run an Ubuntu pod that you can use as a client:
  16. kubectl run -i --tty ubuntu --image=ubuntu:16.04 --restart=Never -- bash -il
  17. 2. Install the mysql client:
  18. $ apt-get update && apt-get install mysql-client -y
  19. 3. Connect using the mysql cli, then provide your password:
  20. $ mysql -h {{ template "mysql.fullname" . }} -p
  21. To connect to your database directly from outside the K8s cluster:
  22. {{- if contains "NodePort" .Values.service.type }}
  23. MYSQL_HOST=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath='{.items[0].status.addresses[0].address}')
  24. MYSQL_PORT=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "mysql.fullname" . }} -o jsonpath='{.spec.ports[0].nodePort}')
  25. {{- else if contains "ClusterIP" .Values.service.type }}
  26. MYSQL_HOST=127.0.0.1
  27. MYSQL_PORT={{ .Values.service.port }}
  28. # Execute the following command to route the connection:
  29. kubectl port-forward svc/{{ template "mysql.fullname" . }} {{ .Values.service.port }}
  30. {{- end }}
  31. mysql -h ${MYSQL_HOST} -P${MYSQL_PORT} -u root -p${MYSQL_ROOT_PASSWORD}