通过Helm创建一个tomcat
一:先通过helm命令生成一个服务部署的模板,会生成默认的配置文件
[root@k8s-master1 helm]# helm create tomcat
Creating tomcat
[root@k8s-master1 helm]# ls -ltr
total 0
drwxr-xr-x 4 root root 93 Jan 2 14:37 tomcat
[root@k8s-master1 helm]# tree tomcat
tomcat
├── charts
├── Chart.yaml
├── templates
│ ├── deployment.yaml
│ ├── _helpers.tpl
│ ├── hpa.yaml
│ ├── ingress.yaml
│ ├── NOTES.txt
│ ├── serviceaccount.yaml
│ ├── service.yaml
│ └── tests
│ └── test-connection.yaml
└── values.yaml
3 directories, 10 files
二:编辑Helm部署应用的配置文件(values.yaml)
[root@k8s-master1 tomcat]# cat values.yaml
# Default values for tomcat.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1 #pod启动的副本数
image: #容器镜像相关的配置
repository: 192.168.21.121:5000/app/tomcat #拉取的镜像地址及名称
pullPolicy: IfNotPresent #pod的镜像拉取策略
# Overrides the image tag whose default is the chart appVersion.
tag: "8.5.34-jre8-alpine" #pod镜像的版本号
imagePullSecrets: #pod镜像拉取时的身份验证
- name: registry-pull-secret
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
podAnnotations: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service: #service的配置
type: ClusterIP #service的类型
port: 8080 #service服务的端口
ingress: #ingress服务的配置
enabled: false
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources: #pod启动CPU和内存的限制
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
nodeSelector: #pod启动node节点的选择
apps: host1
tolerations: []
affinity: {}
probe: #pod探针的配置
livenessProbe:
enabled: true # 是否启用存活探针
initialDelaySeconds: 30 # 在容器启动后多久开始进行首次探测
periodSeconds: 10 # 探测间隔时间(秒)
timeoutSeconds: 5 # 探测超时时间(秒)
successThreshold: 1 # 连续成功多少次才被认为是健康的
failureThreshold: 3 # 连续失败多少次才认为是不健康的
tcpSocket:
port: 8080
readinessProbe:
# 同样的结构,用于定义就绪探针配置
enabled: true
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
tcpSocket:
port: 8080