zoukankan      html  css  js  c++  java
  • k8s 1.9 安装

    测试环境

    主机 系统
    master CentOS 7.3
    node CentOS 7.3

    2.关闭selinux(所有节点都执行)

    [root@matser ~]# getenforce 
    Disabled

    3.关闭swap分区(所有节点都执行)

    [root@matser ~]# swapoff -a
    [root@matser ~]# free -h
                  total        used        free      shared  buff/cache   available
    Mem:           1.8G        502M        117M        2.0M        1.2G        1.1G
    Swap:            0B          0B          0B
    

    4.设置sshd   keepalive(所有节点都执行)

    echo "ClientAliveInterval 10" >> /etc/ssh/sshd_config
    echo "TCPKeepAlive yes" >> /etc/ssh/sshd_config
    systemctl restart sshd.service

    5.安装docker(所有节点都执行)

     yum install -y docker
    systemctl enable docker && systemctl start docker

    6.设置路由(所有节点都执行)

    cat <<EOF >  /etc/sysctl.d/k8s.conf
    net.bridge.bridge-nf-call-ip6tables = 1
    net.bridge.bridge-nf-call-iptables = 1
    EOF
    sysctl --system

    7.安装kubeadmkubeletkubectl(所有节点都执行)

    cat <<EOF > /etc/yum.repos.d/kubernetes.repo
    [kubernetes]
    name=Kubernetes
    baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
    enabled=1
    gpgcheck=1
    repo_gpgcheck=1
    gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
    EOF
    
    yum install -y kubelet kubeadm kubectl
     systemctl enable kubelet && systemctl start kubelet

    8.初始化指定kubernetes版本,并设置一下pod-network-cidr(master)

     kubeadm init --kubernetes-version=v1.9.0 --pod-network-cidr=10.244.0.0/16


    [root@matser ~]# kubeadm init --kubernetes-version=v1.9.0 --pod-network-cidr=10.244.0.0/16
    [init] Using Kubernetes version: v1.9.0
    [init] Using Authorization modes: [Node RBAC]
    [preflight] Running pre-flight checks.
    [WARNING Hostname]: hostname "matser" could not be reached
    [WARNING Hostname]: hostname "matser" lookup matser on 100.100.2.136:53: no such host
    [WARNING FileExisting-crictl]: crictl not found in system path
    [certificates] Generated ca certificate and key.
    [certificates] Generated apiserver certificate and key.
    [certificates] apiserver serving cert is signed for DNS names [matser kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 172.31.1.1]
    [certificates] Generated apiserver-kubelet-client certificate and key.
    [certificates] Generated sa key and public key.
    [certificates] Generated front-proxy-ca certificate and key.
    [certificates] Generated front-proxy-client certificate and key.
    [certificates] Valid certificates and keys now exist in "/etc/kubernetes/pki"
    [kubeconfig] Wrote KubeConfig file to disk: "admin.conf"
    [kubeconfig] Wrote KubeConfig file to disk: "kubelet.conf"
    [kubeconfig] Wrote KubeConfig file to disk: "controller-manager.conf"
    [kubeconfig] Wrote KubeConfig file to disk: "scheduler.conf"
    [controlplane] Wrote Static Pod manifest for component kube-apiserver to "/etc/kubernetes/manifests/kube-apiserver.yaml"
    [controlplane] Wrote Static Pod manifest for component kube-controller-manager to "/etc/kubernetes/manifests/kube-controller-manager.yaml"
    [controlplane] Wrote Static Pod manifest for component kube-scheduler to "/etc/kubernetes/manifests/kube-scheduler.yaml"
    [etcd] Wrote Static Pod manifest for a local etcd instance to "/etc/kubernetes/manifests/etcd.yaml"
    [init] Waiting for the kubelet to boot up the control plane as Static Pods from directory "/etc/kubernetes/manifests".
    [init] This might take a minute or longer if the control plane images have to be pulled.
    [apiclient] All control plane components are healthy after 50.001758 seconds
    [uploadconfig] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
    [markmaster] Will mark node matser as master by adding a label and a taint
    [markmaster] Master matser tainted and labelled with key/value: node-role.kubernetes.io/master=""
    [bootstraptoken] Using token: e03777.05d943f3d7c05ff1
    [bootstraptoken] Configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials
    [bootstraptoken] Configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token
    [bootstraptoken] Configured RBAC rules to allow certificate rotation for all node client certificates in the cluster
    [bootstraptoken] Creating the "cluster-info" ConfigMap in the "kube-public" namespace
    [addons] Applied essential addon: kube-dns
    [addons] Applied essential addon: kube-proxy

    
    

    Your Kubernetes master 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

    
    

    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 machines by running the following on each node
    as root:

    
    

    kubeadm join --token e03777.05d943f3d7c05ff1 172.31.1.1:6443 --discovery-token-ca-cert-hash sha256:40abf04eaea9097377b2b3def894a4a2540a353ac76bc918ca6c18549193f45c

     

    8.设置变量(master)

     export KUBECONFIG=/etc/kubernetes/admin.conf
    echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile

    9.配置网络Flannel(master)

     kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/kube-flannel.yml
    
    ##查看
    [root@matser ~]# kubectl get pods --all-namespaces
    NAMESPACE     NAME                             READY     STATUS    RESTARTS   AGE
    default       nginx                            1/1       Running   0          15s
    kube-system   etcd-matser                      1/1       Running   0          4m
    kube-system   kube-apiserver-matser            1/1       Running   0          3m
    kube-system   kube-controller-manager-matser   1/1       Running   0          4m
    kube-system   kube-dns-6f4fd4bdf-lrt5x         3/3       Running   0          4m
    kube-system   kube-flannel-ds-9rfcs            1/1       Running   0          3m
    kube-system   kube-flannel-ds-fh2pw            1/1       Running   0          1m
    kube-system   kube-proxy-czxhz                 1/1       Running   0          1m
    kube-system   kube-proxy-t9php                 1/1       Running   0          4m
    kube-system   kube-scheduler-matser            1/1       Running   0          3m

    10.加入nodes(node端)

    在node端执行

    [root@node ~]#  kubeadm join --token e03777.05d943f3d7c05ff1 172.31.1.1:6443 --discovery-token-ca-cert-hash sha256:40abf04eaea9097377b2b3def894a4a2540a353ac76bc918ca6c18549193f45c
    [preflight] Running pre-flight checks.
        [WARNING FileExisting-crictl]: crictl not found in system path
    [discovery] Trying to connect to API Server "172.31.1.1:6443"
    [discovery] Created cluster-info discovery client, requesting info from "https://172.31.1.1:6443"
    [discovery] Requesting info from "https://172.31.1.1:6443" again to validate TLS against the pinned public key
    [discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server "172.31.1.1:6443"
    [discovery] Successfully established connection with API Server "172.31.1.1:6443"
    
    This node has joined the cluster:
    * Certificate signing request was sent to master and a response
      was received.
    * The Kubelet was informed of the new secure connection details.
    
    Run 'kubectl get nodes' on the master to see this node join the cluster.

    11.master端查看

    [root@matser ~]# kubectl  get node
    NAME      STATUS    ROLES     AGE       VERSION
    matser    Ready     master    23m       v1.9.4
    node      Ready     <none>    19m       v1.9.4
  • 相关阅读:
    面试题3,求101-200之间有多少个素数,并且输出所有素数
    面试题2,兔子问题
    plsql 导入导出表数据与表结构
    plsql 的各个窗口区别
    oracle cmd命令
    ora-01017 用户名密码未登录
    PLSQL登录报错ORA-12154
    看oracle 的数据库位数
    plsql Developer 登录oracle出现 initialization error
    plsql dev 12 版下载地址
  • 原文地址:https://www.cnblogs.com/zhangb8042/p/8557052.html
Copyright © 2011-2022 走看看