47 lines
1.3 KiB
Markdown
47 lines
1.3 KiB
Markdown
create namespace
|
||
|
||
kubectl apply -f namespace.yaml
|
||
|
||
|
||
# 查看 namespace
|
||
kubectl get namespace --show-labels
|
||
kubectl config view | grep namespace:
|
||
# 切换默认namespace
|
||
kubectl config current-context
|
||
kubectl config set-context test --namespace=app01 \
|
||
--cluster=docker-desktop \
|
||
--user=docker-desktop
|
||
|
||
kubectl config set-context prod --namespace=production \
|
||
--cluster=docker-desktop \
|
||
--user=docker-desktop
|
||
kubectl config view
|
||
# 切换环境到DEV
|
||
kubectl config use-context test
|
||
# check 当前环境
|
||
kubectl config current-context
|
||
# 查看配额
|
||
kubectl get resourcequotas
|
||
kubectl get resourcequota app01-redis --output=yaml
|
||
|
||
# create configmap
|
||
kubectl create configmap app01-redis-conf --from-file=redis.conf
|
||
|
||
kubectl get configmap -n miles-app01
|
||
|
||
NAME DATA AGE
|
||
kube-root-ca.crt 1 3m30s
|
||
miles-app01-redis-conf 1 20s
|
||
|
||
# 创建和查看 pod
|
||
kubectl apply -f app01_redis.yaml
|
||
kubectl get pods -n app01
|
||
|
||
# 注意:configMap 会挂在 /usr/local/etc/redis/redis.conf 上。与 mountPath 和 configMap 下的 path 一同指定
|
||
|
||
kubectl get pod miles-app01-redis-b48ff8c66-q5cv2 -n miles-app01
|
||
kubectl run busybox --image=busybox --command -- ping baidu.com
|
||
kubectl exec -it busybox -- /bin/bash
|
||
k describe replicaset.apps/app01-redis-64847ffc48
|
||
k get all -ALL
|
||
k describe pods |