How To Deploy Service To Cluster Through "Helm"

ngovu.dl@gmail.com | 270 day | 351


In previous articles, I talked about how to set up a "Kubernetes". Today I will talk how to deploy services to k8s through "Helm".

How to setup k8s-helm?

First access with an administrator.

sudo -i

 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.

./install-helm.sh

c-sharp.vn

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

c-sharp.vn

To verify it works.

kubectl get pods --namespace kube-system

c-sharp.vn

 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

helm install --name <Your-name> ./<Your-name>

 c-sharp.vn

 and then you open k8s dashboard will see service on it.

c-sharp.vn

Then you will execute a command like below and check your service.

ubectl port-forward <Pod-Name> 8080:80

c-sharp.vn

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.


Top Articles

Bất Đầu Với WebApi Và Dot Net Core (.Net Core)

1131 day
Butter Ngo
Views 6822
Comments 0

Repository Và Unit Of Work (Entity Framework)

1050 day
ndtung449@gmail.com
Views 4161
Comments 0

Dot Net Core Bearer Token With (JWT) (.Net Core)

1063 day
Butter Ngo
Views 4156
Comments 0

Bắt Đầu Với Dot NET Core (.Net Core)

1142 day
Butter Ngo
Views 3833
Comments 0

Top Question

Bi lỗi Invalid Column Name khi sử dụng LinQ (.Net)

990 day
Bảo Dương
Views 1058
Answers 2

Làm thế nào để lấy information từ token (.Net Core)

380 day
ngovu.dl@gmail.com
Views 604
Answers 1

.NET CORE API JWT (.Net Core)

283 day
huynhminhnhut97@gmail.com
Views 594
Answers 2