自定义Chart-不使用"values.yaml"
(1)清空Chart模板,用于自定义
rm -rf baimeilinux/templates/*
(2)清空values文件
> baimeilinux/values.yaml
(3)自定义Chart信息
cat > baimeilinux/Chart.yaml <<'EOF'
apiVersion: v2
name: baimeilinux
description: baimei linux86 k8s tomcat demo deploy
type: application
version: "v0.1"
appVersion: "1.0"
EOF
(4)创建资源清单
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
spec:
replicas: 1
selector:
matchExpressions:
- key: app
operator: Exists
template:
metadata:
labels:
app: baimei-mysql
spec:
volumes:
- name: data
nfs:
server: master231
path: /baimei/data/kubernetes/tomcat-db
containers:
- name: mysql
image: harbor.baimei.com/baimei-db/mysql:5.7
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: '123456'
volumeMounts:
- name: data
mountPath: /var/lib/mysql
---
apiVersion: v1
kind: Service
metadata:
name: baimei-mysql
spec:
selector:
app: baimei-mysql
ports:
- port: 3306
targetPort: 3306
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: baimei-tomcat-app
spec:
replicas: 1
selector:
matchExpressions:
- key: app
operator: Exists
template:
metadata:
labels:
app: baimei-tomcat-app
spec:
containers:
- name: tomcat
image: harbor.baimei.com/baimei-tomcat/tomcat-app:v1
ports:
- containerPort: 8080
env:
- name: MYSQL_SERVICE_HOST
value: baimei-mysql
- name: MYSQL_SERVICE_PORT
value: '3306'
---
apiVersion: v1
kind: Service
metadata:
name: baimei-tomcat-app
spec:
type: NodePort
selector:
app: baimei-tomcat-app
ports:
- port: 8080
targetPort: 8080
nodePort: 8080
(5)安装自定义Chart
helm install linux86-tomcat baimeilinux -n baimei-helm
(6)自定义安装的提示信息
echo "welcome to use ... www.baimei.com" > baimeilinux/templates/NOTES.txt
(7)卸载Chart服务
helm uninstall -n baimei-helm linux86-tomcat
欢迎来撩 : 汇总all