Helm Introduction
Deploying container cloud Applications (container or microservices orchestration) in Kubernetes is a challenging task, Helm is to simplify the installation of a client tool for deploying container cloud applications in Kubernetes. Helm enables developers to define, install, and upgrade container cloud applications in Kubernetes. At the same time, the container cloud application can also be shared through helm.
Gitlab helm chart
The overall architecture of Helm is shown in the image source-kubernetes Chinese community:levon helm
Jenkins helm chart
The helm architecture consists of the helm client, heather helm the tiller server and the chart warehouse, Tiller deployed in Kubernetes, max helm the helm client obtains the chart installation package from the chart warehouse and deploys its installation to the Kubernetes cluster.
Prometheus helm chart
Helm is a tool for managing kubernetes packages, Helm can provide the following capabilities:anne helm
- Create a new charts
- Package charts into a tgz file
- Interacting with the chart warehouse
- Installation and uninstallation of kubernetes applications
- Manage the life cycle of charts installed with Helm
In helm, there are three important concepts to understand:
- Chart: is a collection of information that creates an Kubernetes app instance
- Config: Configuration information for the chart that created the publication object
- A running instance of Release:chart that contains a specific config
Installing Helm
Note: Some files or images may not be available for download at home and can be obtained at this address: Https://pan.baidu.com/s/1yVUCz7wGYie8hkzQaNc3eg
Helm chart tutorial
1. Download the installation Helm client in master, grafana helm chart download the corresponding version as needed, the version used here is 2.8.2.
Curl-lo https://storage.googleapis.com/kubernetes-helm/helm-v2.8.2-linux-amd64.tar.gz
Tar xzf helm-v2.8.2-linux-amd64.tar.gz
MV Linux-amd64/helm/usr/local/bin
Helm version View information:helm charts
The server tiller is not yet installed, so information cannot be obtained.
Note: If helm-v2.8.2-linux-amd64.tar.gz cannot be downloaded, it can be obtained from the link above.
2. Install the tiller.
Helm Init
Note: If initialization fails, you can copy the. Helm directory from the link above into the root directory of master. Tiller image files can also be obtained from the directory.
If there is a "error:get https://10.96.0.1:443/version:dial TCP 10.96.0.1:443:i/o timeout." Question, you can refer to my answer to solve:
https://github.com/kubernetes/helm/issues/3347#issuecomment-385468128
Use Helm version to view the helm versions, which indicate that the client and server are installed:
The Kubernetes 1.6+ version joins the RBAC mechanism, so you need to add role Binding:
KUBECTL Create clusterrolebinding add-on-cluster-admin--clusterrole=cluster-admin--serviceaccount=kube-system: Default
Preparing Java MicroServices
1. Packaging jars
MVN Package
2. Prepare Dockerfile
From java:8u111-///AppCMD ["java","- xmx4g","-djava.security.egd=file:/dev/./urandom"," -jar ","hello-1.0.0.jar"]
3. Copy the packaged jar package and dockerfile to node virtual machine
4. Package Docker image
Docker build-t hello:1.0.0.
Preparing a. Net Core micro-service
1. Publish the Project
dotnet Publish-c Release
2. Prepare Dockerfile
From Microsoft/aspnetcore:2.0///tcpenv aspnetcore_urls http: //*:5000entrypoint ["dotnet"] HelloTest.dll"]
3. Copy the packaged package and Dockerfile to the node virtual machine
4. Package Docker image
Docker build-t hello-test:1.0.0.
Using the Helm Deployment Blueprint (Chart)
Here is how to complete the deployment of the above two microservices via helm.
1. Create chart
Helm Create Hello-test
2. Put the appropriate deployment script in the Templates directory
3. Package Chart
Helm Package Hello-test
4. Check Chart
Helm Lint Hello-test
The chart icon is missing, but not affected, and can be ignored.
5. Debug chart
Helm install./hello-test-0.1.0.tgz--debug--dry-run
Debug mode is not actually deployed, and is viewed through the helm list:
6. Deploy release via chart
Helm install--name hello-test./hello-test-0.1.0.tgz
Helm ls
Kubectl Get PO
View Results
Java Services:
. Net Core Services (invoking the Java service):
7. Delete Release
Helm Delete Hello-test
Kubectl Get PO
Helm Ls-a
Hello-test is still in, but the state is deleted, which means that it can be reused. If you want to remove it completely, you can delete it by Helm delete Hello-test--purge.
Using. Net Core for deployment
The components used are: https://github.com/qmfrederik/helm/.
1. Core code:
[Route ("api/releases")] Public classreleasecontroller:controller{[HttpPost ("{Name}")] Public AsyncTask<iactionresult> Install (stringname, Iformfile file) { varClient =awaitgetclient (); using(varstream =NewMemoryStream ()) { awaitfile. Copytoasync (stream); varChart =Chartpackage.open (stream); varRelease =awaitClient. Installrelease (chart. Serialize (),string. Empty, Name,true); returnOk (release. Manifest); }} [Httpdelete ("{Name}/{purge}")] Public AsyncTask<iactionresult> Uninstall (stringNameBOOLpurge) { varClient =awaitgetclient (); varresult =awaitclient. Uninstallrelease (name, purge); returnOk (result. Info); } [Httpput ("{Name}")] Public AsyncTask<iactionresult> Update (stringname, Iformfile file) { varClient =awaitgetclient (); using(varstream =NewMemoryStream ()) { awaitfile. Copytoasync (stream); varChart =Chartpackage.open (stream); varRelease =awaitClient. Updaterelease (chart. Serialize (),string. Empty, name); returnOk (release. Manifest); }} [Httpput ("{name}/{version}")] Public AsyncTask<iactionresult> Rollback (stringNameintversion) { varClient =awaitgetclient (); varresult =awaitclient. Rollbackrelease (name, version); returnOk (result. Info); } Private Static AsyncTask<tillerclient>getclient () {varKubeconfig = System.IO.File.ReadAllText ("admin.conf"); varConfig =Kubernetesclientconfiguration.buildconfigfromconfigfile (kubeconfig:kubeconfig); varKubernetes =NewKubernetes (config); varLocator =NewTillerlocator (kubernetes); varEndPoint =awaitLocator. Locate (); varClient =Newtillerclient (endpoint.tostring ()); returnclient; }}
Note: You need to obtain Kubernetes's Admin.config certificate, which is on the master node:/etc/kubernetes/admin.conf.
2. Follow the steps above to prepare the. Net core microservices to complete the helm-client image packaging and deployment.
Note: You need to copy the admin.conf to the Mirror:
3. Prepare the Yaml file Helm-client.yaml and complete the deployment
Apiversion:extensions/v1beta1kind:deploymentmetadata: name:helm-client Labels: app:helm-client namespace:defaultspec: replicas:1 Template: metadata: Labels: app:helm-client Spec: nodeselector: kubernetes.io/role:node containers: -name:helm-client Image: helm-client:1.0.0 Ports: -containerport:5000---kind:ServiceapiVersion:v1metadata: name: Helm-client Labels: app:helm-client namespace:defaultspec: selector: app:helm-client type:nodeport Ports: -name:helm-client nodeport:30000 port:5000 protocol:tcp targetport:5000
4. Check the effect
Installation:
Delete:
Source Address
Https://github.com/ErikXu/HelmTutorial
The Helm-kubernetes of service orchestration