Kubernetes DaemonSet 使用
2024-01-09 21:38:56 554
需求如下:
某类pod需要在指定节点运行
且每个节点只能有一个pod运行
滚动更新时需保证可用性
---
apiVersion: v1
kind: Service
metadata:
name: rbac-service
labels:
app: rbac-svc
spec:
selector:
app: rbac-pod
type: NodePort
ports:
- name: http
protocol: TCP
port: 11008
targetPort: 11008
nodePort: 11008
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: rbac-monitor
spec:
selector:
matchLabels:
app: rbac-pod
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 2
maxUnavailable: 0
template:
metadata:
labels:
app: rbac-pod
spec:
containers:
- name: rbac
image: xxx
imagePullPolicy: Always
ports:
- containerPort: 11008
name: "http"
workingDir: /home/rbac
command: [ "java" ]
args: [
"-jar",
"rbac.jar"
]
readinessProbe:
httpGet:
path: /app/status
port: 11008
initialDelaySeconds: 20
timeoutSeconds: 30
periodSeconds: 30
livenessProbe:
httpGet:
path: /app/status
port: 11008
initialDelaySeconds: 15
timeoutSeconds: 30
periodSeconds: 30
nodeSelector:
monitor: log
dnsPolicy: ClusterFirst
imagePullSecrets:
- name: harbor-pri-sec