In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "the actual use and development of Helm3". In the daily operation, I believe many people have doubts about the actual use and development of Helm3. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "the actual use and development of Helm3". Next, please follow the editor to study!
Use
Now let's introduce the simple use of the v3 version.
First of all, we can download the corresponding binaries for the 3.x.x version from github and put the helm program in the PATH directory.
Simply verify the availability of the program by executing the following command:
$helm-- helpThe Kubernetes package managerCommon actions for Helm:- helm search: search for charts- helm pull: download a chart to your local directory to view- helm install: upload the chart to Kubernetes- helm list: list releases of chartsEnvironment variables:+-+-- -- + | Name | Description | + -+ | $XDG_CACHE_HOME | set an alternative location for storing cached files. | | $XDG_CONFIG_HOME | set an alternative location for storing Helm configuration. | | | $XDG_DATA_HOME | set an alternative location for storing Helm data. | | | $HELM_DRIVER | set the backend storage driver. | Values are: configmap, secret, memory | | $HELM_NO_PLUGINS | disable plugins. Set HELM_NO_PLUGINS=1 to disable plugins. | | $KUBECONFIG | set an alternative Kubernetes configuration file (default "~ / .kube / config") | +-+-- +.
You can see the command parameters and configuration variables for helm.
As mentioned above, the v3 version no longer requires Tiller, but interacts with K8s through ApiServer. You can set the environment variable KUBECONFIG to specify the address of ApiServre and the address of the configuration file of token. The default is ~ / .kube / config. There are many tutorials on the Internet that explain how to configure, so I won't repeat them here.
After configuring the environment variable KUBECONFIG and the configuration file, you can use it normally:
Test the installation:
# generate chart file $helm create fooCreating foo# package $helm package fooSuccessfully packaged chart and saved it to: / home/test/helm/foo-0.1.0.tgz# install $helm install foo. / foo-0.1.0.tgzNAME: fooLAST DEPLOYED: Sat Dec 7 21:05:33 2019NAMESPACE: defaultSTATUS: deployedREVISION: 1NOTES:1. Get the application URL by running these commands: export POD_NAME=$ (kubectl get pods-namespace default-l "app.kubernetes.io/name=foo App.kubernetes.io/instance=foo "- o jsonpath=" {.items [0] .metadata.name} ") echo" Visit http://127.0.0.1:8080 to use your application "kubectl-- namespace default port-forward $POD_NAME 8080 echo query release$helm lsNAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSIONfoo default 1 2019- 12-07 21 foo 05VR 33.355624435 + 0800 CST deployed foo-0.1.0 1.16.0 # Delete release$helm delete foorelease "foo" uninstalled
Repo related operations:
# add warehouse $helm repo add {warehouse name} {warehouse address} "{warehouse name}" has been added to your repositories# query warehouse list $helm repo listNAME URL {warehouse name} {warehouse address} # query chart package $helm search repo# delete warehouse $helm repo remove {warehouse name } "{warehouse name}" has been removed from your repositories
Other commands of helm can be viewed through the introduction in help, and there are many related introductions on the Internet. Next, we will introduce how to carry out secondary development based on helm api.
Development based on Helm
Helm is written in golang like other K8s components. If you are a beginner of golang and have K8s operation and maintenance experience, helm source code can be used as one of the ways for you to deeply understand K8s design concepts.
Because helm is a client-class program, the code is organized, hierarchical, and rarely uses golang features (such as goroutine), so the source code is not too complicated to read.
After looking at some of the helm source code, I summarized the following points:
For golang beginners, learn the go language by reading the helm source code and how to use golang to develop command interaction applications as elegantly as helm.
For K8s operation and maintenance personnel, some operation and maintenance tools for K8s can be developed based on helm to improve the efficiency of operation and maintenance.
Understand the design ideas of helm and chart, and learn the design concepts
Use materials
To make a long story short, the first step is of course to prepare the environment and install the following programs:
Golang version > = 1.11
Git bash
Go ide (goland/vs code)
Helm uses go mod as a package management tool. It is recommended to install golang with a version greater than 1.11, because this version has built-in go mod, which is similar to maven in java, which makes it easy to download and manage dependent packages.
Configure go mod proxy
As the download dependency in the domestic environment is relatively slow, we need to set up a go mod agent to accelerate. Here I use https://goproxy.io/.
Configure the following environment variables:
# Enable the go modules featureexport GO111MODULE=on# Set the GOPROXY environment variableexport GOPROXY= https://goproxy.io create Project
You can directly git clone my sample project on github under {gopath} / src
Or you can create a new project and introduce helm dependencies into the go.mod file:
Require (... Helm.sh/helm/v3 v3.0.0.) replace (/ / github.com/Azure/go-autorest/autorest has different versions for the Go / / modules than it does for releases on the repository. Note the correct / / version when updating. Github.com/Azure/go-autorest/autorest = > github.com/Azure/go-autorest/autorest v0.9.0 github.com/docker/docker = > github.com/moby/moby v0.7.3-0.20190826074503-38ab9da00309 / / Kubernetes imports github.com/miekg/dns at a newer version but it is used / / by a package Helm does not need. Go modules resolves all packages rather / / than just those in use (like Glide and dep do). This sets the version / / to the one oras needs. If oras is updated the version should be updated / / as well. Github.com/miekg/dns = > github.com/miekg/dns v0.0.0-20181005163659-0d29b283ac0f gopkg.in/inf.v0 v0.9.1 = > github.com/go-inf/inf v0.9.1 gopkg.in/square/go-jose.v2 v2.3.0 = > github.com/square/go-jose v2.3.0+incompatible rsc.io/letsencrypt = > github.com/dmcgowan/letsencrypt v0.0.0-20160928181947-1847a81d2087)
Replace configuration is essential, which can replace some dependencies that can not be found, such as
The docker project has been renamed to moby, so replace github.com/docker/docker with github.com/moby/moby through replace configuration
Download dependency
Execute the following command to place the dependency package in the vendor directory under the project:
Go mod vendor
After the download is successful, we can begin our development journey.
Helm source code structure and development ideas ├── cmd/ helm cli code ├── pkg/ helm api code, we really need to pay attention to the ├── script/ some scripts.
Helm uses cobra to develop command interaction functions (such as helm list [flags]), and the related code is in the cmd directory.
For example, the installation command install, defined in the cmd/helm/install.go file, calls the Run () method in pkg/action/install.go to perform the installation operation.
Each command of helm can find the corresponding api method in the pkg directory, understand the meaning of the parameters of these methods, and you can fully use the power of helm.
Is it quite simple, and then we can use the native capabilities of helm to develop our own programs flexibly, including:
Packing
Check format
Rebuild the index
Install chart
Query release
.
With these capabilities, you can develop a chart visual UI of your own style like helm/monocular.
At this point, the study on "the actual use and development of Helm3" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.