Use helm in Kubernetes


Helm is the package manager for Kubernetes, you can think it as yum/apt/homebrew. It contains two parts: Server (tiller) and Client (helm). helm client can be installed on Linux/Mac/Windows, the package can be found here.

Helm manages the Kubernetes charts which are pre-configured Kubernetes resources. In the following example, I will show you how to install Prometheus by using helm.

    1. Setup RABC for helm (tiller) to use, the sample config file:
      apiVersion: v1
      kind: ServiceAccount
      metadata:
        name: tiller
        namespace: kube-system
      ---
      apiVersion: rbac.authorization.k8s.io/v1beta1
      kind: ClusterRoleBinding
      metadata:
        name: tiller
      roleRef:
        apiGroup: rbac.authorization.k8s.io
        kind: ClusterRole
        name: cluster-admin
      subjects:
        - kind: ServiceAccount
          name: tiller
          namespace: kube-system
      
    2. Initialize helm and update repository
      helm init --service-account tiller
      helm repo update
      
    3. Install Prometheus and configure the ingress for the services. I use the Kubernetes cluster that is built by kops, and I will continue use the example domain k8s-01.nprod.my.com. Please change it accordingly.
      helm install stable/Prometheus \
      --set alertmanager.ingress.enabled=true \
      --set "alertmanager.ingress.hosts={alertmanager.k8s-01.nprod.my.com}" \
      --set pushgateway.ingress.enabled=true \
      --set "pushgateway.ingress.hosts={pushgateway.k8s-01.nprod.my.com}" \
      --set server.ingress.enabled=true \
      --set "server.ingress.hosts={server.k8s-01.nprod.my.com}"
      
    4. If you installed it successfully, it should like this:
      helm-prome.png
    5. Add alias records in Route 53 for server.k8s-01.nprod.my.com and other services to point to ELB. Then test it, you should see the Prometheus page.
      helm-prome1
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s