跳到正文
LEo的网络日志
返回

cka注意事项

source <(kubectl completion bash) # setup autocomplete in bash into the current shell, bash-completion package should be installed first.
echo "source <(kubectl completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shel
alias k=kubectl
complete -F __start_kubectl k
export do="--dry-run=client -o yaml"    # k get pod x $do
export now="--force --grace-period 0"   # k delete pod x $now
kubectl config use-context target-cluster
systemctl daemon-reload && systemctl restart kubelet

systemctl status kubelet
k api-resources --namespaced -o name
-o name
--no-headers
-o wide
kubectl run --help | grep "kubectl run"
  kubectl run nginx --image=nginx
  kubectl run hazelcast --image=hazelcast/hazelcast --port=5701
  kubectl run hazelcast --image=hazelcast/hazelcast --env="DNS_DOMAIN=cluster" --env="POD_NAMESPACE=default"
  kubectl run hazelcast --image=hazelcast/hazelcast --labels="app=hazelcast,env=prod"
  kubectl run nginx --image=nginx --dry-run=client
  kubectl run nginx --image=nginx --overrides='{ "apiVersion": "v1", "spec": { ... } }'
  kubectl run -i -t busybox --image=busybox --restart=Never
  kubectl run nginx --image=nginx -- <arg1> <arg2> ... <argN>
  kubectl run nginx --image=nginx --command -- <cmd> <arg1> ... <argN>
  kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...] [options]

kubectl create deployment nginx --image=nginx  # start a single instance of nginx

# create a Job which prints "Hello World"
kubectl create job hello --image=busybox -- echo "Hello World" 

# create a CronJob that prints "Hello World" every minute
kubectl create cronjob hello --image=busybox   --schedule="*/1 * * * *" -- echo "Hello World" 
cat << EOF > test.log
line1
line2
EOF
cat << EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
  name: busybox-sleep
spec:
  containers:
  - name: busybox
    image: busybox
    args:
    - sleep
    - "1000000"
---
apiVersion: v1
kind: Secret
metadata:
  name: mysecret
type: Opaque
data:
  password: $(echo -n "s33msi4" | base64 -w0)
  username: $(echo -n "jane" | base64 -w0)
EOF

:) 未完待续…



上一篇
cka练习(十六)
下一篇
argocd学习(一)