minikube安装
##minikube offical website https://minikube.sigs.k8s.io #k8s offical website https://kubernetes.io/zh/ --download # Intel x86_64 curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 # Apple arm64 curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-arm64 #install sudo install minikube /usr/local/bin/ #version minikube version #install kubectl minikube kubectl #start cluster,specify docker as the driver minikube start --driver=docker --kubernetes-version=v1.23.3 --force #view cluster status and node list minikube status minikube node list #为命令指定别名 alias kubectl="minikube kubectl --" #启动一个pod kubectl run ngx --image=nginx:alpine #查看插件列表 minikube addons list #查看dashboard minikube dashboard #查看支持的对象 kubectl api-resources kubectl api-resources #查看kubectl底层调用 kubectl get pod --v=9 #查看k8s对象的属性 kubectl explain pod kubectl explain pod.metadata kubectl explain pod.spec kubectl explain pod.spec.containers #生成一个空的pod的yaml模板,而不真正执行 kubectl run ngx2 --image=nginx:alpine --dry-run=client -o yaml kubectl run busy --image=busybox:latest --dry-run=client -o yaml #生成pod之外的模板文件 #创建job kubectl create job echo-job --image=busybox --dry-run=client -o yaml #创建cronJob kubectl create cj echo-cj --image=busybox --schedule="" --dry-run=client -o yaml #删除pod kubectl delete po ngx kubectl delete -f ngx2.yaml #描述pod详细信息 kubectl describe pod busy-pod #复制一个文件到pod kubectl cp a.txt ngx2:/tmp #在容器执行shell kubectl exec -it ngx2 -- sh #创建configmap kubectl create cm cm_info --dry-run=client -o yaml #创建secret kubectl create secret generic user --from-literal=name=root --dry-run=client -o yaml #生成base64编码 echo -n "123456" | base64
configMap模板
apiVersion: v1
kind: ConfigMap
metadata:
name: cminfo
data:
count: '10'
debug: 'on'
path: '/etc/systemd'
greeting: 'say hello to kubernetes'
secret模板
apiVersion: v1
kind: Secret
metadata:
name: user
data:
name: cm9vdA==
pwd: MTIzNDU2
pod模板
apiVersion: v1标签:kubectl,run,name,部署,--,minikube,pod From: https://www.cnblogs.com/wangbin2188/p/17109862.html
kind: Pod
metadata:
labels:
run: busy
name: busy
spec:
containers:
- image: busybox:latest
name: busy
imagePullPolicy: IfNotPresent
env:
- name: os
valueFrom:
configMapKeyRef:
name: cminfo
key: count
- name: debug
valueFrom:
secretKeyRef:
name: user
key: pwd
command:
- /bin/echo
args:
- "$(os), $(debug)"
dnsPolicy: ClusterFirst
restartPolicy: Always