ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Kubernetes---01安装

2021-10-08 02:00:07  阅读:113  来源: 互联网

标签:01 Kubernetes k8s system 192.168 --- -- kube


使用Nexus做镜像仓库、代理http,去下载谷歌的k8s组件镜像

官网:https://www.sonatype.com/  下载安装包解压及安装。

运行:nexus.exe /run  访问:http://localhost:8081/   默认用户 admin 密码存在nexus-3.34.1-01-win64\sonatype-work\nexus3\admin.password

1.设置代理

 

 

2.创建仓库

+ hosted: 托管仓库 ,私有仓库,可以push和pull

+ proxy: 代理和缓存远程仓库 ,只能pull

+ group: 将多个proxy和hosted仓库添加到一个组,只访问一个组地址即可,只能pull

代理url https://k8s.gcr.io 、https://gcr.io  、https://registry-1.docker.io 还建了个组仓库

 

组建k8s高可用集群三控制平面多node详见另篇博客:https://blog.csdn.net/l619872862/article/details/110087605

 

 

组建1控制平面多node:

  准备工作:

    集群中的所有机器的网络彼此均能相互连接

    节点之中不可以有重复的主机名、MAC 地址或 product_uuid

    关闭swap

    端口开放:

      控制平面节点:6443、2379-2380、10250、10251、10252

      工作节点:10250、30000-32767

    加载br_netfilter ip_vs ip_vs_rr ip_vs_wrr ip_vs_sh nf_conntrack_ipv4 模块(注意:使用nf_conntrack而不是nf_conntrack_ipv4用于 Linux 内核 4.19 及更高版本)

    安装docker

    安装 kubeadm、kubelet 和 kubectl

    确保docker和 kubelet 所使用的是相同的 cgroup 驱动

[root@k8s-01 ~]# cat /etc/docker/daemon.json 
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2",
  "insecure-registries": ["192.168.1.2:8550"],
  "registry-mirrors": ["http://192.168.1.2:8550"]
}

初始化:

#kubeadm config images pull --image-repository 192.168.1.2:8550 可以提前先拉取镜像

kubeadm init  --service-cidr 10.96.0.0/16 --pod-network-cidr 10.244.0.0/16 --control-plane-endpoint 192.168.1.15  --image-repository 192.168.1.2:8550 --upload-certs

[addons] Applied essential addon: kube-proxy

Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

Alternatively, if you are the root user, you can run:

  export KUBECONFIG=/etc/kubernetes/admin.conf

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

You can now join any number of the control-plane node running the following command on each as root:

  kubeadm join 192.168.1.15:6443 --token fc3a7i.i0yovz66e1qfvitj \
        --discovery-token-ca-cert-hash sha256:4b3ff7faccbc8d73cfef2bfe299b816177f2a849fc78946cec1eb8a4b4c86afa \
        --control-plane --certificate-key 50736746046b79987ceb159f376d128933ab233d613f5bfe44d83d4dcd0efdaf

Please note that the certificate-key gives access to cluster sensitive data, keep it secret!
As a safeguard, uploaded-certs will be deleted in two hours; If necessary, you can use
"kubeadm init phase upload-certs --upload-certs" to reload certs afterward.

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 192.168.1.15:6443 --token fc3a7i.i0yovz66e1qfvitj \
        --discovery-token-ca-cert-hash sha256:4b3ff7faccbc8d73cfef2bfe299b816177f2a849fc78946cec1eb8a4b4c86afa 

网络插件:kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

最后该加控制面的加控制面,该加节点的加节点;

 

[root@k8s-01 ~]# kubectl get node
NAME     STATUS   ROLES                  AGE     VERSION
k8s-01   Ready    control-plane,master   20m     v1.22.2
k8s-04   Ready    <none>                 6m34s   v1.22.2
k8s-05   Ready    <none>                 5m32s   v1.22.2

[root@k8s-01 ~]# kubectl get pod -A -o wide
NAMESPACE     NAME                             READY   STATUS    RESTARTS   AGE   IP             NODE     NOMINATED NODE   READINESS GATES
kube-system   coredns-54c76d684c-gbfhj         1/1     Running   0          25m   10.244.0.2     k8s-01   <none>           <none>
kube-system   coredns-54c76d684c-w892g         1/1     Running   0          25m   10.244.0.3     k8s-01   <none>           <none>
kube-system   etcd-k8s-01                      1/1     Running   0          25m   192.168.1.15   k8s-01   <none>           <none>
kube-system   kube-apiserver-k8s-01            1/1     Running   0          25m   192.168.1.15   k8s-01   <none>           <none>
kube-system   kube-controller-manager-k8s-01   1/1     Running   0          25m   192.168.1.15   k8s-01   <none>           <none>
kube-system   kube-flannel-ds-cwx64            1/1     Running   0          12m   192.168.1.10   k8s-04   <none>           <none>
kube-system   kube-flannel-ds-cxrdp            1/1     Running   0          18m   192.168.1.15   k8s-01   <none>           <none>
kube-system   kube-flannel-ds-svc86            1/1     Running   0          11m   192.168.1.13   k8s-05   <none>           <none>
kube-system   kube-proxy-jkgws                 1/1     Running   0          25m   192.168.1.15   k8s-01   <none>           <none>
kube-system   kube-proxy-pw6qr                 1/1     Running   0          12m   192.168.1.10   k8s-04   <none>           <none>
kube-system   kube-proxy-wb7hm                 1/1     Running   0          11m   192.168.1.13   k8s-05   <none>           <none>
kube-system   kube-scheduler-k8s-01            1/1     Running   0          25m   192.168.1.15   k8s-01   <none>           <none>

 

  

 

标签:01,Kubernetes,k8s,system,192.168,---,--,kube
来源: https://www.cnblogs.com/xiaoming619872862/p/15377572.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有