# (2) 第三方Chart仓库添加/查看/更新/删除 # 官网需要翻墙: helm repo add stable https://charts.helm.sh/stable ~$ helm repo add stable https://charts.helm.sh/stable # "stable" has been added to your repositories ~$ helm repo add azure http://mirror.azure.cn/kubernetes/charts # ~$ helm repo add aliyun https://apphub.aliyuncs.com/ ~$ helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts # "aliyun" has been added to your repositories ~$ helm repo list # NAME URL # stable http://mirror.azure.cn/kubernetes/charts # aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts ~$ helm repo update # Hang tight while we grab the latest from your chart repositories... # ...Successfully got an update from the "aliyun" chart repository # ...Successfully got an update from the "stable" chart repository # Update Complete. ⎈Happy Helming!⎈ ~$ helm repo remove aliyun # "aliyun" has been removed from your repositories
# (3) 应用搜索(搜索使用模糊字符串匹配算法) ~$ helm search hub redis # Helm 官网Chart仓库中心 # URL CHART VERSION APP VERSION DESCRIPTION # https://hub.helm.sh/charts/drycc-canary/redis 1.0.0 A Redis database for use inside a Kubernetes cl... # https://hub.helm.sh/charts/groundhog2k/redis 0.1.2 6.0.9 A Helm chart for Redis on Kubernetes # https://hub.helm.sh/charts/wener/redis 12.1.1 6.0.9 Open source, advanced key-value store. It is of... ....
~$ helm search repo dashboard | grep -v "DEPRECATED"# 第三方 Chart 仓库 # NAME CHART VERSION APP VERSION DESCRIPTION # aliyun/kubernetes-dashboard 0.6.0 1.8.3 General-purpose web UI for Kubernetes clusters # aliyun/jasperreports 0.2.5 6.4.2 The JasperReports server can be used as a stand... # aliyun/kube-ops-view 0.4.1 Kubernetes Operational View - read-only system ... # aliyun/uchiwa 0.2.3 Dashboard for the Sensu monitoring framework # aliyun/weave-cloud 0.1.2 Weave Cloud is a add-on to Kubernetes which pro... # aliyun/weave-scope 0.9.2 1.6.5 A Helm chart for the Weave Scope cluster visual...
# SVC ~/K8s/Day10/demo1$ kubectl get svc # NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE # hello-world-svc NodePort 10.103.145.171 <none> 80:30080/TCP 3m37s
# Deployment ~/K8s/Day10/demo1$ kubectl get deploy -o wide --show-labels # NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR LABELS # hello-world-deployment 1/1 1 1 5m3s nginx-hello harbor.weiyigeek.top/test/nginx:v1.0 app=hello-world app.kubernetes.io/managed-by=Helm,app=hello-world
# Pod ~/K8s/Day10/demo1$ kubectl get pod -o wide --show-labels # NAME READY STATUS RESTARTS AGE IP NODE LABELS # hello-world-deployment-588f974b64-d8456 1/1 Running 0 3m55s 10.244.2.34 k8s-node-5 app=hello-world,pod-template-hash=588f974b64
~/K8s/Day10/demo1$ helm search repo redis # NAME CHART VERSION APP VERSION DESCRIPTION # aliyun/redis 1.1.15 4.0.8 Open source, advanced key-value store. It is of... # aliyun/redis-ha 2.0.1 Highly available Redis cluster with multiple se...
# 4.支持多种安装方式:(helm默认读取~/.kube/config信息连接k8s集群) # $ helm install redis stable/redis # $ helm install redis redis-4.4.0.tgz # $ helm install redis redis/ # $ helm install redis https://example.com/charts/redis-4.4.0.tgz ~/K8s/Day10/demo2$ helm install redis redis/ # NAME: redis # LAST DEPLOYED: Wed Nov 25 21:55:53 2020 # NAMESPACE: default # STATUS: deployed # REVISION: 1 # TEST SUITE: None # NOTES: # Redis can be accessed via port 6379 on the following DNS name from within your cluster: # redis-redis.default.svc.cluster.local # To get your password run: # REDIS_PASSWORD=$(kubectl get secret --namespace default redis-redis -o jsonpath="{.data.redis-password}" | base64 --decode) # 实际就是上面设置redis密码weiyigeek将它存入了secret中
# To connect to your Redis server: # 1. Run a Redis pod that you can use as a client: # kubectl run --namespace default redis-redis-client --rm --tty -i \ # --env REDIS_PASSWORD=$REDIS_PASSWORD \ # --image bitnami/redis:4.0.8-r2 -- bash
# 2. Connect using the Redis CLI: # redis-cli -h redis-redis -a $REDIS_PASSWORD
# (1) Pod 查看 ~/K8s/Day10/demo2/redis$ kubectl get pod -o wide # NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES # redis-redis-84db677d99-mb2m4 1/1 Running 0 11m 10.244.2.49 k8s-node-5 <none> <none>
# (2) 进入Pod的Shell之中 $ kubectl exec -it redis-redis-84db677d99-mb2m4 -- bash I have no name!@redis-redis-84db677d99-mb2m4:/$ cat /bitnami/redis/conf/redis.conf | grep "weiyi" # requirepass weiyigeek I have no name!@redis-redis-84db677d99-mb2m4:/$ ls # app-entrypoint.sh bin bitnami boot dev entrypoint.sh etc home init.sh lib lib64 media mnt opt proc redis-inputs.json root run run.sh sbin srv sys tmp usr var I have no name!@redis-redis-84db677d99-mb2m4:/$ ls /bitnami/ # redis
# (3) 连接测试Redis REDIS_PASSWORD=$(kubectl get secret --namespace default redis-redis -o jsonpath="{.data.redis-password}" | base64 --decode) ~/K8s/Day10/demo2$ redis-cli -h 10.244.2.49 -a $REDIS_PASSWORD 10.244.2.47:6379> ping PONG 10.244.2.47:6379> info # Server redis_version:4.0.8 ...... 10.244.2.47:6379> set name weiyigeek OK 10.244.2.47:6379> KEYS * 1) "name" 10.244.2.47:6379> GET name "weiyigeek" 10.244.2.47:6379> save # 将 数据 存储进Redis 文件 dump.rdb 以便后续重启redis后数据依然存在; OK
# (4) 查看存放的dump.rdb文件 ~/K8s/Day10/demo2/redis$ ls /nfs/data2/redis/data/ # appendonly.aof dump.rdb
Step 5.验证持久化操作设置
1 2 3 4 5 6 7 8 9
~/K8s/Day10/demo2/redis/templates$ kubectl delete pod redis-redis-84db677d99-mb2m4 # pod "redis-redis-84db677d99-mb2m4" deleted
~/K8s/Day10/demo2/redis/templates$ kubectl get pod -o wide # redis-redis-84db677d99-5cjnk 1/1 Running 0 26s 10.244.2.50 k8s-node-5
~/K8s/Day10/demo2/redis/templates$ redis-cli -h 10.244.2.50 -a $REDIS_PASSWORD # 10.244.2.50:6379> get name # "weiyigeek"
# (1) 添加harbor的chartrepo URL到Helm本地仓库中 ~/K8s/Day10/demo1$ helm repo add local https://harbor.weiyigeek.top/chartrepo/test --insecure-skip-tls-verify "local" has been added to your repositories
# (2) index 生成以及将push 图表 到库中 ~/K8s/Day10/demo1$ helm repo index . --url https://harbor.weiyigeek.top/chartrepo/test ~/K8s/Day10/demo1$ helm push --insecure -u weiyigeek -p Harbor12345 hello-world-1.0.0.tgz local # Pushing hello-world-1.0.0.tgz to local... # Done.
# (1) 仓库更新 $ helm repo update Hang tight while we grab the latest from your chart repositories... ...Successfully got an update from the "local" chart repository ...Successfully got an update from the "aliyun" chart repository ...Successfully got an update from the "stable" chart repository Update Complete. ⎈Happy Helming!⎈
# (2) 搜索我们上传的Chart应用 ~/K8s/Day10$ helm search repo hello-world NAME CHART VERSION APP VERSION DESCRIPTION local/hello-world 1.0.0 latest A Helm chart for Kubernetes Hello Wrold
- 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 charts
Environment variables:
| Name | Description | |------------------------------------|-----------------------------------------------------------------------------------| | $HELM_CACHE_HOME | set an alternative location for storing cached files. | | $HELM_CONFIG_HOME | set an alternative location for storing Helm configuration. | | $HELM_DATA_HOME | set an alternative location for storing Helm data. | | $HELM_DEBUG | indicate whether or not Helm is running in Debug mode | | $HELM_DRIVER | set the backend storage driver. Values are: configmap, secret, memory, postgres | | $HELM_DRIVER_SQL_CONNECTION_STRING | set the connection string the SQL storage driver should use. | | $HELM_MAX_HISTORY | set the maximum number of helm release history. | | $HELM_NAMESPACE | set the namespace used for the helm operations. | | $HELM_NO_PLUGINS | disable plugins. Set HELM_NO_PLUGINS=1 to disable plugins. | | $HELM_PLUGINS | set the path to the plugins directory | | $HELM_REGISTRY_CONFIG | set the path to the registry config file. | | $HELM_REPOSITORY_CACHE | set the path to the repository cache directory | | $HELM_REPOSITORY_CONFIG | set the path to the repositories file. | | $KUBECONFIG | set an alternative Kubernetes configuration file (default "~/.kube/config") | | $HELM_KUBEAPISERVER | set the Kubernetes API Server Endpoint for authentication | | $HELM_KUBEASGROUPS | set the Groups to use for impersonation using a comma-separated list. | | $HELM_KUBEASUSER | set the Username to impersonate for the operation. | | $HELM_KUBECONTEXT | set the name of the kubeconfig context. | | $HELM_KUBETOKEN | set the Bearer KubeToken used for authentication. |
Helm stores cache, configuration, and data based on the following configuration order:
- If a HELM_*_HOME environment variable is set, it will be used - Otherwise, on systems supporting the XDG base directory specification, the XDG variables will be used - When no other location is set a default location will be used based on the operating system
By default, the default directories depend on the Operating System. The defaults are listed below:
Available Commands: completion generate autocompletions script for the specified shell create create a new chart with the given name dependency manage a chart\'s dependencies env helm client environment information get download extended information of a named release help Help about any command history fetch release history install install a chart lint examine a chart for possible issues list list releases package package a chart directory into a chart archive plugin install, list, or uninstall Helm plugins pull download a chart from a repository and (optionally) unpack it in local directory repo add, list, remove, update, and index chart repositories rollback roll back a release to a previous revision search search for a keyword in charts show show information of a chart status display the status of the named release template locally render templates test run tests for a release uninstall uninstall a release upgrade upgrade a release verify verify that a chart at the given path has been signed and is valid version print the client version information Flags: --debug enable verbose output -h, --help help for helm --kube-apiserver string the address and the port for the Kubernetes API server --kube-as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups. --kube-as-user string Username to impersonate for the operation --kube-context string name of the kubeconfig context to use --kube-token string bearer token used for authentication --kubeconfig string path to the kubeconfig file -n, --namespace string namespace scope for this request --registry-config string path to the registry config file (default "/home/weiyigeek/.config/helm/registry.json") --repository-cache string path to the file containing cached repository indexes (default "/home/weiyigeek/.cache/helm/repository") --repository-config string path to the file containing repository names and URLs (default "/home/weiyigeek/.config/helm/repositories.yaml") Use "helm [command] --help" for more information about a command.
0x04 模板编写
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
~/K8s/Day10/demo2$ cat redis/Chart.yaml appVersion: 4.0.8 description: Open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets. engine: gotpl home: http://redis.io/ icon: https://bitnami.com/assets/stacks/redis/img/redis-stack-220x234.png keywords: - redis - keyvalue - database maintainers: - email: containers@bitnami.com name: bitnami-bot name: redis sources: - https://github.com/bitnami/bitnami-docker-redis version: 1.1.15
方式1.请访问本博主的B站【WeiyiGeek】首页关注UP主, 将自动随机获取解锁验证码。
Method 2.Please visit 【My Twitter】. There is an article verification code in the homepage.
方式3.扫一扫下方二维码,关注本站官方公众号
回复:验证码
将获取解锁(有效期7天)本站所有技术文章哟!