CKA实验
type
status
date
slug
summary
tags
category
icon
password
Pod
统计pod的数量
kubectl get pods
创建一个nginx的镜像
kubectl run nginx --image=nginx
生成一个yaml文件但是不创建镜像
kubectl run nginx --image=nginx --dry-run=client -o yaml
运行redis123的pod
kubectl run redis --image=redis123 --dry-run=client -o yaml > redis-definition.yaml
创建redis-definition.yaml的pod
kubectl create -f redis-definition.yaml
ReplicaSets
获取replicaset的信息
kubectl get replicaset OR controlplane ~ ➜ kubectl get rs NAME DESIRED CURRENT READY AGE frontend-deployment-577494fd6f 4 4 0 2m9s
replicaset的详细信息
kubectl describe replicaset new-replca-set
获取replicaset中pod是的详细信息
kubectl describe pod new-replica-set-xxxx
删除replicaset
kubectl delete rs replicaset-x
复制新的副本集
kubectl edit rs new-replca-set
Deployment
查看部署的数量
kubectl get deployment OR controlplane ~ ➜ kubectl get deploy NAME READY UP-TO-DATE AVAILABLE AGE frontend-deployment 0/4 4 0 18s
查看部署的详细信息
kubectl describe deploy
创建nginx的部署
kubectl create deployment --image=nginx nginx
生成一个yaml文件但是不创建部署
kubectl create deployment --image=nginx nginx --dry-run=client -o yaml
生成一个yaml文件但是不创建部署并将它保存到文件中
kubectl create deployment --image=nginx nginx --dry-run=client -o yaml > nginx-deployment.yaml
添加副本然后创建部署
kubectl create -f nginx-deployment.yaml
在 k8s 版本 1.19+ 中,指定–replicas创建4个副本的部署
kubectl create deployment --image=nginx nginx --replicas=4 --dry-run=client -o yaml > nginx-deployment.yaml
Service
查看service的数量
kubectl get svc OR controlplane ~ ➜ kubectl get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 37m
查看service的详细信息
kubectl describe service
创建yaml服务
kubectl apply -f service-definition-1.yaml