切换用户 su root 123456 wh 123456
创建namespace kubectl create ns dev 查看命名空间 kubectl get ns 删除ns kubectl delete ns dev
pod中运行nginx kubectl run nginx --image=nginx:1.17.1 --port=80 --namespace=dev
查看dev的pod kubectl get pod -n dev kubectl get pod -n dev -o wide kubectl describe pod nginx-64777cd554-lwjqr -n dev 删除pod kubectl delete pod nginx-64777cd554-lwjqr -n dev 查看pod控制器 kubectl get deployment -n dev 删除控制器,然后才能删除pod kubectl delete deployment nginx -n dev
查看label kubectl get pod -n dev --show-labels 加标签 kubectl label pod nginx-69cf67d555-dzbft -n dev version=1.0 修改标签 kubectl label pod nginx-69cf67d555-dzbft -n dev version=1.1 --overwrite
带着deployment kubectl run nginx --image=nginx:1.17.1 --port=81 --namespace=dev --replicas=3 --namespace=dev
1 查看linux版本 cat /etc/redhat-release -> CentOS Linux release 7.9.2009 (Core)
2 主机名解析 /etc/hosts 文件写入 192.168.159.129 master
3 时间同步
4 关闭iptables 和firewalld 服务
5禁用selinux getenforce 看状态 vim /etc/selinux/config
6 禁用swap 分区
7 修改内核参数 vim /etc/sysctl.d/k8s.conf net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 net.ipv4.ip_forward=1
安装docker wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
yum install --setopt=obsoletes=0 docker-ce-18.06.3.ce-3.el7 -y
kubeadm config images list k8s.gcr.io/kube-apiserver:v1.17.17 k8s.gcr.io/kube-controller-manager:v1.17.17 k8s.gcr.io/kube-scheduler:v1.17.17 k8s.gcr.io/kube-proxy:v1.17.17 k8s.gcr.io/pause:3.1 k8s.gcr.io/etcd:3.4.3-0 k8s.gcr.io/coredns:1.6.5
docker pull registry.aliyuncs.com/google_containers/kube-apiserver:v1.17.17 docker pull registry.aliyuncs.com/google_containers/kube-controller-manager:v1.17.17 docker pull registry.aliyuncs.com/google_containers/kube-scheduler:v1.17.17 docker pull registry.aliyuncs.com/google_containers/kube-proxy:v1.17.17 docker pull registry.aliyuncs.com/google_containers/pause:3.1 docker pull registry.aliyuncs.com/google_containers/etcd:3.4.3-0 docker pull registry.aliyuncs.com/google_containers/coredns:1.6.5
docker tag registry.aliyuncs.com/google_containers/kube-apiserver:v1.17.17 k8s.gcr.io/kube-apiserver:v1.17.17 docker tag registry.aliyuncs.com/google_containers/kube-controller-manager:v1.17.17 k8s.gcr.io/kube-controller-manager:v1.17.17 docker tag registry.aliyuncs.com/google_containers/kube-scheduler:v1.17.17 k8s.gcr.io/kube-scheduler:v1.17.17 docker tag registry.aliyuncs.com/google_containers/kube-proxy:v1.17.17 k8s.gcr.io/kube-proxy:v1.17.17 docker tag registry.aliyuncs.com/google_containers/pause:3.1 k8s.gcr.io/pause:3.1 docker tag registry.aliyuncs.com/google_containers/etcd:3.4.3-0 k8s.gcr.io/etcd:3.4.3-0 docker tag registry.aliyuncs.com/google_containers/coredns:1.6.5 k8s.gcr.io/coredns:1.6.5
docker rmi registry.aliyuncs.com/google_containers/kube-apiserver:v1.17.17 docker rmi registry.aliyuncs.com/google_containers/kube-controller-manager:v1.17.17 docker rmi registry.aliyuncs.com/google_containers/kube-scheduler:v1.17.17 docker rmi registry.aliyuncs.com/google_containers/kube-proxy:v1.17.17 docker rmi registry.aliyuncs.com/google_containers/pause:3.1 docker rmi registry.aliyuncs.com/google_containers/etcd:3.4.3-0 docker rmi registry.aliyuncs.com/google_containers/coredns:1.6.5
虚拟机IP地址变 你可以在/etc/sysconfig/network-scripts/ifcfg-eth0 中 BOOTPROTO=static ONBOOT=“yes” IPADDR=192.168.159.103 GATEWAY=192.168.159.2 NETMASK=255.255.255.0 onboot=yes kubeadm init –apiserver-advertise-address=192.168.159.101 –image-repository registry.aliyuncs.com/google_containers –kubernetes-version v1.17.4 –service-cidr=10.96.0.0/12 –pod-network-cidr=10.244.0.0/16
|