How to setup k8s-helm?
First access with an administrator.
Download and install on your cluster (master node) with commands like below
cd /tmp curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > install-helm.sh
Grant permission for the helm
chmod u+x install-helm.sh
To verify it works.
When you see the result like above, mean it's work.
Next, We will setup Tiller-Server, so what's Tiller:
Tiller is a companion to the helm command that runs on your cluster, receiving commands from helm and communicating directly with the Kubernetes API to do the actual work of creating and deleting resources. To give Tiller the permissions it needs to run on the cluster, we are going to make a Kubernetes serviceaccount resource.
Note: We will bind this serviceaccount to the cluster-admin cluster role. This will give the tiller service superuser access to the cluster and allow it to install all resource types in all namespaces. This is fine for exploring Helm, but you may want a more locked-down configuration for a production Kubernetes cluster.
Please refer to the official Helm RBAC documentation for more information on setting up different RBAC scenarios for Tiller.
So we will create a Tiller account with commands like below:
kubectl -n kube-system create serviceaccount tiller kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
After executing the commands above, we need to check its work with command like below:
helm init --service-account tiller
To verify it works.
kubectl get pods --namespace kube-system
How to deploy services to the cluster through helm?
Create a helm with commands like below:
helm create <Your-name>
Please note that the name of the chart provided here will be the name of the directory where the chart is createdand stored.
Let's quickly see the directory structure created for us:
<Your-name> / Chart.yaml values.yaml templates / charts / .helmignore
Let's understand the relevance of these files and folders created for us:
- Chart.yaml: This is the main file that contains the description of our chart
- values.yaml: this is the file that contains the default values for our chart
- templates: This is the directory where Kubernetes resources are defined as templates
- charts: This is an optional directory that may contain sub-charts
- .helmignore: This is where we can define patterns to ignore when packaging (similar in concept to .gitignore)
Open folder templates you will see a structure like below:
templates / deployment.yaml service.yaml ingress.yaml ......
About deployment and service, you can get information from here.
Inspect helm variable with command like below:
helm template ./hello-world
helm install --name <Your-name> ./<Your-name>
and then you open k8s dashboard will see service on it.
Then you will execute a command like below and check your service.
ubectl port-forward <Pod-Name> 8080:80
And final some handy "Helm" commands
helm create <Your-name> helm lint ./<Your-name> helm template ./<Your-name> helm install --name <Your-name> ./<Your-name> helm upgrade oauth-server ./<Your-name> helm delete --purge <Your-name>
And this is an article guide you on how to create a helm. So done now, I hope the article can help your work, and next article I will guide how to deploy istio gateway to k8s. If you have any question do not hesitate comment below.