Open jinleileiking opened 1 year ago
https://kubernetes.io/zh/docs/tasks/tools/install-kubectl-macos/
创建 ~/.kube/config 文件,将控制台的kubeconfig拷入即可
[jinleileiking:~/.kube] master(+27/-27)* ± kubectl cluster-info
Kubernetes control plane is running at xxxxxx
metrics-server is running at xxxxx/api/v1/namespaces/kube-system/services/heapster/proxy
KubeDNS is running at xxxxxxxx/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
如果你用zsh, oh-my-zsh,
使用ohmyzsh的plugin:
我用zplug管理:改~/.vimrc 装zplug,并在vimrc添加:
zplug "plugins/kubectl", from:oh-my-zsh
然后:
[jinleileiking:~/.kube] master(+27/-27)* ± alias | grep kube | head
k=kubectl
kaf='kubectl apply -f'
kca='_kca(){ kubectl "$@" --all-namespaces; unset -f _kca; }; _kca'
kccc='kubectl config current-context'
kcdc='kubectl config delete-context'
kcgc='kubectl config get-contexts'
kcn='kubectl config set-context --current --namespace'
kcp='kubectl cp'
kcsc='kubectl config set-context'
kcuc='kubectl config use-context'
这样就方便多了
kubens 用于换环境 kubectx 用于换namespace
aliyun
kubectl create secret docker-registry regsecret --docker-server=registry.cn-zhangjiakou.aliyuncs.com --docker-username=xxxx --docker-password=xxxxxxx
注意image不要带https!service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type: "intranet"
. https://help.aliyun.com/document_detail/86531.htm?spm=a2c4g.11186623.0.0.2bacc00dVOK3Y7#task-1425948systemctl restart rsyslog
---未验证/run/containerd/io.containerd.runtime.v2.task/k8s.io
cat /etc/kubernetes/kubelet-customized-args.conf
https://segmentfault.com/a/1190000022163856pvc
k8s to sls
* and eventId.reason: Started
相关告警即可, 用自带的那个好像不好使(也许好使),但是即使好使,也无法展现podnamesls 数据加工
gitlab
-f ./trunk/Dockerfile .
sudo docker build-t rdqa/zzzzzz:test -f ./trunk/Dockerfile .
docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
docker push registry.cn-zhangjiakou.aliyuncs.com/xxxx/zzzzz:test
standard_init_linux.go:211: exec user process caused "exec format error"
在m1编的镜像 linux用不了 : https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/4558image:entrypoint
total:\s+\(statements\)\s+(\d+.\d+\%)
To push a commit without triggering a pipeline, add [ci skip] or [skip ci], using any capitalization, to your commit message.
yum install a && yum install b 改为 install a b && yum clean all && rm -rf /var/cache/yum
strategy: depend
No permissions to trigger downstream pipeline
提升commiter的权限就好了,不知道为啥[-red-]
[-green-]
[-red-] [-green-]docker
docker login不要sudo ....
没办法给一个启动的docker expose端口 : https://stackoverflow.com/questions/19897743/exposing-a-port-on-a-live-docker-container.
-p 8935:1935
docker run -v /xxxxxxxxx/trunk:/srstrunk --name srs3 -P -dit srsdev /bin/bash
起个centos:
docker run -it centos
有些镜像设置了启动命令不是shell,你要进sh,怎么办?
docker run --entrypoint '/bin/sh' -it k8s.gcr.io/kustomize/kustomize:v3.8.7
docker pull超出dockerhub次数: https://cloud.tencent.com/developer/article/1701933(未验证)
alpine/git没有bash, docker:latest没有git, bash+git就乖乖centos+git把
地方不够,dockerbuild: 重启不了docker的话,删了重装。。。。
overlay目录清理:
sudo docker system prune -a -f
docker开发srs
cicd
jenkins X
argocd
kubectl get Application -n argocd
然后delete,但是不行,改一下finilizer:finalizer: []
. done.helm template . <options> | kubectl apply -f -
argo rollout
aliyun asm
k8s
KUBE_EDITOR="nano"
kubectl get pod -o=custom-columns=NAME:.metadata.name,STATUS:.status.phase,NODE:.spec.nodeName --all-namespaces
dig srv srs-origin-service.wzjinlei.svc.cluster.local
SRV.NS.svc.cluster.local.kubectl delete pods <pod> --grace-period=0 --force
kubectl get pods | grep redash | awk '{print $1}' | xargs kubectl delete pod --grace-period=0 --force
kubectl get po --all-namespaces -o=jsonpath="{range .items[*]}{.metadata.namespace}:{.metadata.name}{''}{range .spec.containers[*]} {.name}:{.resources.requests.cpu}{'\n'}{end}{'\n'}{end}" | grep -e ':\d*m'
alias util='kubectl get nodes --no-headers | awk '\''{print $1}'\'' | xargs -I {} sh -c '\''echo {} ; kubectl describe node {} | grep Allocated -A 5 | grep -ve Event -ve Allocated -ve percent -ve -- ; echo '\'''
.kubectl describe nodes
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
访问模式有: ReadWriteOnce 卷可以被一个节点以读写方式挂载。 ReadWriteOnce 访问模式也允许运行在同一节点上的多个 Pod 访问卷。 ReadOnlyMany 卷可以被多个节点以只读方式挂载。 ReadWriteMany 卷可以被多个节点以读写方式挂载。 ReadWriteOncePod 卷可以被单个 Pod 以读写方式挂载。 如果你想确保整个集群中只有一个 Pod 可以读取或写入该 PVC, 请使用ReadWriteOncePod 访问模式。这只支持 CSI 卷以及需要 Kubernetes 1.22 以上版本。
https://www.qikqiak.com/post/boosting-kubeclt-productivity/
k cp ns/pod:x.log ./a
kustomize
helm
helm template --debug
比 helm lint方便, lint解决不了,用template看看原因{{range $i, $e := until (.Values.replicas | int)}} {{$i}} {{end}}
如果报float的话,用int: spec.persistentvolumesource is immutable after creation
: 要把所有的用pvc的pod停了就行 scale.{{ .Release.Namespace }}
prometheus
快速调试
发现了一个在k8s快速调试的办法,在本地build latest镜像,然后push 覆盖云上的,imagepull改为always,deletepod,新pod就会用最新的代码重启了
tips