Helm is a package manager for Kubernetes. We can compare it with apt for Ubuntu, yum for Centos and Homebrew for macOS.
Let’s take a quick look at how to install, configure, and utilize Helm.
$ brew install kubernetes-helm
$ helm init
$ helm repo update
Install an application with Helm
First update the repo :
$ helm repo update
Next, we’ll install for exemple package mysql:
$ helm install stable/mysql
# The chart also enables the developer to add notes:
To get your root password run:
MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace default loopy-gerbil-mysql -o jsonpath="{.data.mysql-root-password}" | base64 --decode; echo)
To connect to your database:
1. Run an Ubuntu pod that you can use as a client:
kubectl run -i --tty ubuntu --image=ubuntu:16.04 --restart=Never -- bash -il
2. Install the mysql client:
$ apt-get update && apt-get install mysql-client -y
3. Connect using the mysql cli, then provide your password:
$ mysql -h loopy-gerbil-mysql -p
To connect to your database directly from outside the K8s cluster:
MYSQL_HOST=127.0.0.1
MYSQL_PORT=3306
# Execute the following command to route the connection:
kubectl port-forward svc/loopy-gerbil-mysql 3306
mysql -h ${MYSQL_HOST} -P${MYSQL_PORT} -u root -p${MYSQL_ROOT_PASSWORD}
Get the mysql password
$ kubectl get secret --namespace default loopy-gerbil-mysql -o jsonpath="{.data.mysql-root-password}" | base64 --decode; echo
macbook-pro-rcherara:Projects rcherara$ kubectl get secrets
NAME TYPE DATA AGE
default-token-d72m7 kubernetes.io/service-account-token 3 11h
loopy-gerbil-mysql Opaque 2 7m
macbook-pro-rcherara:Projects rcherara$ kubectl get secret loopy-gerbil-mysql -o yaml
apiVersion: v1
data:
mysql-password: Znc2Vk04aXhMSw==
mysql-root-password: NjNGM2Z5Q25mZg==
kind: Secret
metadata:
creationTimestamp: 2018-12-21T20:02:56Z
labels:
app: loopy-gerbil-mysql
chart: mysql-0.11.0
heritage: Tiller
release: loopy-gerbil
name: loopy-gerbil-mysql
namespace: default
resourceVersion: "7668"
selfLink: /api/v1/namespaces/default/secrets/loopy-gerbil-mysql
uid: 68412ae2-055b-11e9-9e5f-dadaa0a9b8eb
type: Opaque
macbook-pro-rcherara:Projects rcherara$ echo "NjNGM2Z5Q25mZg==" | base64 --decode
63F3fyCnff
macbook-pro-rcherara:Projects rcherara$