CKA-Day02:工作负载、存储
1、部署、滚动更新、回滚
Deployments
使用set image命令更新镜像
kb get deploy -owide
kb get pod -w
rollout history
rollout status
rollout undo
暂停、恢复Deployment的上线过程
rollout pause
rollout resume
StatefulSet
kb create sts -h 命令行不能创建sts资源?
spec:
podManagementPolicy: OrderedReady
replicas: 3
revisionHistoryLimit: 10
selector:
matchLabels:
app: nginx
serviceName: nginx
template:
metadata:
creationTimestamp: null
labels:
app: nginx
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
ports:
- containerPort: 80
name: web
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /usr/share/nginx/html
name: www
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 10
updateStrategy:
rollingUpdate:
partition: 0
type: RollingUpdate
volumeClaimTemplates:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
name: www
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: csi-localpv
volumeMode: Filesystem
status:
phase: Pending
访问模式
制备
回收
PersistentVolumeClaim保留
Service
spec:
clusterIP: 246.96.132.18
externalTrafficPolicy: Cluster
ports:
- name: 380-80
nodePort: 30021
port: 380
protocol: TCP
targetPort: 80
selector:
app: nginx
sessionAffinity: None
type: NodePort
2、存储
ConfigMaps
Read-only file system
Secret
kubectl create secret 【Secret类型】 【Secret名称】
kb create secret
Create a secret using specified subcommand.
Available Commands:
docker-registry Create a secret for use with a Docker registry
generic Create a secret from a local file, directory or literal value
tls Create a TLS secret
Usage:
kubectl create secret [flags] [options]
Use "kubectl <command> --help" for more information about a given command.
Use "kubectl options" for a list of global command-line options (applies to all commands).
在使用 echo “secret” |base64 命令时,实际得到的结果是 c2VjcmV0Cg== 而不是 c2VjcmV0,这是因为 echo 命令默认会添加一个换行符(\n)。
所以你实际上是在对 “secret\n” (包含一个换行符)进行 base64 编码,而不只是 “secret”。
如果你想避免 echo 命令添加的换行符,你可以使用 -n 选项,如下:
hostPath
rollout restart sts ?