jinleileiking / learning-notes

Notes for my learning.
GNU General Public License v3.0
1 stars 2 forks source link

k8s #17

Open jinleileiking opened 1 year ago

jinleileiking commented 1 year ago

aliyun

pvc

k8s to sls

{
    "inputs": [
        {
            "detail": {
                "Stderr": true,
                "IncludeLabel": {
                    "io.kubernetes.pod.namespace": "YOUR NS"
                },
                "Stdout": true
            },
            "type": "service_docker_stdout"
        }
    ]
}

sls 数据加工

gitlab

docker

docker开发srs

cicd

argo rollout

aliyun asm

k8s


# Change mongo-75f59d57f4-4nd6q to the name of the Pod
kubectl port-forward mongo-75f59d57f4-4nd6q 28015:27017

kustomize

helm

prometheus

快速调试

发现了一个在k8s快速调试的办法,在本地build latest镜像,然后push 覆盖云上的,imagepull改为always,deletepod,新pod就会用最新的代码重启了

tips

kubectl patch svc sss -n cicd -p '{"spec": {"type": "ClusterIP"}}'

jinleileiking commented 9 months ago

命令安装

mac安装kubectl

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