云原生-CKA笔记:学前准备
主要包括操作系统,docker,k8s资源,yaml语法等基础技能
OS/VM
- Ubuntu
- VirtualBox
- Tencent Cloud
- Aliyun
docker
按官方文档进行安装。
apt-get remove docker docker-engine docker.io containerd runc
apt-get update
apt-get install ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
配置加速镜像
~ #/etc/docker/daemon.json
{
"registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com"]
}
Kubernets’ Resources
PODS, Deployments, Services…
kubectl api-resources
查看所有支持的k8s资源kubectl api-versions
查看所有支持的k8s api版本kubectl explain
查看具体资源的原语详情说明
主要的资源说明
- Nodes,no
- Namespaces,ns
- Pods,po
- Deployments,deploy
- Daemonsets,ds
- Jobs
- CronJobs,cj
- Services,svc
- Ingresses,ing
- ConfigMap,cm
- Secrets
- ServiceAccounts,sa
- PersistentVolumeClaims,pvc
- PersistentVolumes,pv
- Roles; ClusterRoles
- RoleBindings; ClusterRoleBindings
- NetworkPolicies,netpol
YAML
参见百度、知乎。YAML语法介绍…
奇技淫巧
- kubectl 自动补全
echo "source <(kubectl completion bash)" >> ~/.zshrc; source ~/.bashrc
- 快速生成
yaml
基本框架,善用--dry-run=client -o yaml
避免手动敲太多 - 查看
API Resource YAML
原语字段结构的说明,善用kubectl explain [resource[.field]]
相关链接
- YAML语法介绍
-
https://zhuanlan.zhihu.com/p/75067291
- https://docs.docker.com/engine/install/ubuntu/