rancher docker k8s安装
sudo docker run -d --restart=unless-stopped -p 8080:80 -p 443:443 --name=rancher rancher/rancher:stable
sudo docker run --privileged -d --restart=unless-stopped -p 8080:80 -p 443:443 --name=rancher rancher/rancher:stable
apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment namespace: default spec: replicas: 1 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80
apiVersion: v1 kind: Service metadata: name: nginx-service spec: selector: app: nginx ports: - protocol: TCP port: 80 targetPort: 80 type: LoadBalancer
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: nginx-ingress spec: rules: - host: 192.168.215.132 http: paths: - path: / pathType: Prefix backend: service: name: nginx-service port: number: 80
https://files.cnblogs.com/files/shiningrise/k8s.zip?t=1715322780&download=true
kubeadm init --kubernetes-version=v1.28.9 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --ignore-preflight-errors=ImagePull kubeadm init --kubernetes-version=v1.28.9 --ignore-preflight-errors=ImagePull docker pull registry.k8s.io/kube-apiserver:v1.28.9 docker pull kube-controller-manager:v1.28.9 docker pull kube-scheduler:v1.28.9 docker pull kube-proxy:v1.28.9 docker pull registry.k8s.io/pause:3.9 docker pull registry.k8s.io/etcd:3.5.9-0 docker pull registry.k8s.io/coredns/coredns:v1.10.1 docker save -o k8s.tar registry.k8s.io/kube-apiserver:v1.28.9 kube-controller-manager:v1.28.9 kube-scheduler:v1.28.9 kube-proxy:v1.28.9 registry.k8s.io/pause:3.9 registry.k8s.io/etcd:3.5.9-0 registry.k8s.io/coredns/coredns:v1.10.1 docker save -o k8s.tar registry.k8s.io/pause:3.9 registry.k8s.io/etcd:3.5.9-0
添加阿里云的 Kubernetes 源:
sudo tee /etc/apt/sources.list.d/kubernetes.list <<EOF deb http://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main EOF
2. 导入阿里云的 GPG 密钥:
curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add -
systemctl stop ufw && systemctl disable ufw
sudo swapoff -a
sudo modprobe br_netfilter
echo '1' | sudo tee /proc/sys/net/bridge/bridge-nf-call-iptables
sudo nano /etc/sysctl.conf
在文件的末尾添加以下两行配置
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
sudo sysctl -p
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo lsof -i :80
kubeadm config images pull
kubeadm init --kubernetes-version=v1.28.9 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --ignore-preflight-errors=All kubeadm init --kubernetes-version=v1.28.9 --ignore-preflight-errors=All kubeadm init --ignore-preflight-errors=ImagePull docker pull registry.k8s.io/kube-apiserver:v1.28.9 docker pull kube-controller-manager:v1.28.9 docker pull kube-scheduler:v1.28.9 docker pull kube-proxy:v1.28.9 docker pull registry.k8s.io/pause:3.9 docker pull registry.k8s.io/etcd:3.5.9-0 docker pull registry.k8s.io/coredns/coredns:v1.10.1 docker save -o k8s.tar registry.k8s.io/kube-apiserver:v1.28.9 kube-controller-manager:v1.28.9 kube-scheduler:v1.28.9 kube-proxy:v1.28.9 registry.k8s.io/pause:3.9 registry.k8s.io/etcd:3.5.9-0 registry.k8s.io/coredns/coredns:v1.10.1 docker save -o k8s.tar registry.k8s.io/pause:3.9 registry.k8s.io/etcd:3.5.9-0
以下指令适用于 Kubernetes 1.28.
-
更新
apt
包索引并安装使用 Kubernetesapt
仓库所需要的包:sudo apt-get update # apt-transport-https 可能是一个虚拟包(dummy package);如果是的话,你可以跳过安装这个包 sudo apt-get install -y apt-transport-https ca-certificates curl gpg
-
下载用于 Kubernetes 软件包仓库的公共签名密钥。所有仓库都使用相同的签名密钥,因此你可以忽略URL中的版本:
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
-
添加 Kubernetes
apt
仓库。 请注意,此仓库仅包含适用于 Kubernetes 1.28 的软件包; 对于其他 Kubernetes 次要版本,则需要更改 URL 中的 Kubernetes 次要版本以匹配你所需的次要版本 (你还应该检查正在阅读的安装文档是否为你计划安装的 Kubernetes 版本的文档)。# 此操作会覆盖 /etc/apt/sources.list.d/kubernetes.list 中现存的所有配置。 echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
-
更新
apt
包索引,安装 kubelet、kubeadm 和 kubectl,并锁定其版本:sudo apt-get update sudo apt-get install -y kubelet kubeadm kubectl sudo apt-mark hold kubelet kubeadm kubectl
成功部署教程:基于Ubuntu-22.04 kubeadm安装K8s-v1.28.2_kubeadm config images pull-CSDN博客