创建一个demon
helm create test01
tree test01/
test01/
|-- charts
|-- Chart.yaml
|-- templates
| |-- deployment.yaml
| |-- _helpers.tpl
| |-- hpa.yaml
| |-- ingress.yaml
| |-- NOTES.txt
| |-- serviceaccount.yaml
| |-- service.yaml
| `-- tests
| `-- test-connection.yaml
`-- values.yaml
- 删除 templates里的所有文件
[root@jenkins test01]# cd templates/
[root@jenkins templates]# ls
deployment.yaml _helpers.tpl hpa.yaml ingress.yaml NOTES.txt serviceaccount.yaml service.yaml tests
[root@jenkins templates]# rm -rf *
[root@jenkins templates]# ll
total 0
- 尝试运行或者直接把编辑好的yaml文件放置 templates目录里
[root@jenkins templates]# kubectl create deployment web1 --image=nginx:alpine --dry-run -o yaml > deployment.yaml
W0527 00:12:25.437455 24829 helpers.go:553] --dry-run is deprecated and can be replaced with --dry-run=client.
需要创建才能使用以下命令
kubectl create deployment web1 --image=nginx:alpine
kubectl expose deployment web1 --port=80 --target-port=80 --type=NodePort --dry-run -o yaml > service.yaml
- 最后语法检测
[root@node101 ~]# helm lint test01/
==> Linting test01/
[INFO] Chart.yaml: icon is recommended
1 chart(s) linted, 0 chart(s) failed
- 安装
[root@jenkins helm]# helm install web1 test01/
NAME: web1
LAST DEPLOYED: Thu May 27 00:18:04 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
卸载
[root@jenkins ~]# helm uninstall web1
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/config
release "web1" uninstalled
- helm3仓库搭建
cat <END>> helms.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: helm
#namespace: qa
labels:
app: helm
spec:
replicas: 1
selector:
matchLabels:
app: helm
template:
metadata:
labels:
app: helm
spec:
containers:
- name: helm
image: chartmuseum/chartmuseum:latest
ports:
- containerPort: 8080
env:
- name: DEBUG
value: "1"
- name: STORAGE
value: local
- name: STORAGE_LOCAL_ROOTDIR
value: /charts
volumeMounts:
- mountPath: /charts
name: data
volumes:
- name: data
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: helm
#namespace: qa
spec:
type: NodePort
selector:
app: helm
ports:
- port: 8080
targetPort: 8080
nodePort: 30018
END
访问成功
添加两个仓库
helm repo add localrepo http://192.168.8.102:30018
[root@node101 ~]# helm repo add test00 http://192.168.8.102:30018
"test00" has been added to your repositories
打包
[root@node101 ~]# helm package test01/
Successfully packaged chart and saved it to: /root/test01-0.1.0.tgz
安装 helm push 插件
在线安装helm plugin install https://github.com/chartmuseum/helm-push
离线安装 wget https://github-releases.githubusercontent.com/129789275/30fc1c00-0f24-11eb-976c-d95527243443?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210810%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210810T161439Z&X-Amz-Expires=300&X-Amz-Signature=2912e1744c4ceb8a4e430b02130d606add21b475bae68860290cc4b5d159be93&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=129789275&response-content-disposition=attachment%3B%20filename%3Dhelm-push_0.9.0_linux_amd64.tar.gz&response-content-type=application%2Foctet-stream
- 离线安装的方式
tar xvf helm-push_0.9.0_linux_amd64.tar.gz
mkdir -p /root/.local/share/helm/plugins/helm-push
mv bin/ /root/.local/share/helm/plugins/helm-push
mv plugin.yaml /root/.local/share/helm/plugins/helm-push
[root@node101 ~]# helm plugin list
NAME VERSION DESCRIPTION
push 0.9.0 Push chart package to ChartMuseum
- helm push 推送test01
[root@node101 ~]# helm push test01-0.1.0.tgz localrepo
Pushing test01-0.1.0.tgz to localrepo...
Done.
如需有用户密码使用以下方式
helm push grafana-0.0.2.tgz test --username test --password xxx
- 更新生效
[root@node101 ~]# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "chartmuseum" chart repository
...Successfully got an update from the "localrepo" chart repository
...Successfully got an update from the "cilium" chart repository
Update Complete. ⎈Happy Helming!⎈
- 查看仓库内容
[root@node101 ~]# helm search repo localrepo
NAME CHART VERSION APP VERSION DESCRIPTION
localrepo/myapp 0.1.0 1.16.0 A Helm chart for Kubernetes
localrepo/test01 0.1.0 1.16.0 A Helm chart for Kubernetes
或者
curl http://192.168.8.102:30018/api/charts |jq
- 再次安装安装--------------
[root@node101 ~]# helm install test01 localrepo/test01
NAME: test01
LAST DEPLOYED: Wed Aug 11 00:36:22 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
[root@node101 ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
helm-95f74c974-4lf79 1/1 Running 0 115m
postgres-8f747dd98-dcwwg 1/1 Running 3 4d
postgres-8f747dd98-ghss6 1/1 Running 3 4d
postgres-8f747dd98-j4b7k 1/1 Running 3 (3h17m ago) 4d
web1-5d7bdf9b96-jqfrf 1/1 Running 0 4s
helm repo add --username=admin --password=Harbor12345 myrepo http://192.168.75.100:10000/chartrepo/myrepo
helm push --username=admin --password=Harbor12345 app myrepo
版权声明:本文为weixin_42562106原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。