kubespray creates windows server 2019 worker node cluster

Keywords: DNS network Kubernetes JSON

By default, refer to:

https://docs.microsoft.com/en-us/virtualization/windowscontainers/kubernetes/creating-a-linux-master

Based on the above method, kubespray is used for optimization.

1. First, modify the following files:

inventory/your_name/group_vars/k8s-cluster/k8s-cluster.yml

Modification: kube_network_plugin: flannel

2. Check the following documents:

roles/network_plugin/flannel/defaults/main.yml

Ensure: flannel_backend_type: "vxlan"

 

3. Execute the following commands to modify the network configuration

vi roles/network_plugin/flannel/templates/cni-flannel.yml.j2

Mainly change "name":"cni0" to vxlan0:

  cni-conf.json: |
    {
      "name": "vxlan0",
      "plugins": [
        {
          "type": "flannel",
          "delegate": {
            "hairpinMode": true,
            "isDefaultGateway": true
          }
        },
        {
          "type": "portmap",
          "capabilities": {
            "portMappings": true
          }
        }
      ]
    }

Modify net-conf.json, add "VNI": 4096, "Port": 4789:

  net-conf.json: |
    {
      "Network": "{{ kube_pods_subnet }}",
      "Backend": {
        "Type": "{{ flannel_backend_type }}",
        "VNI" : 4096,
        "Port": 4789
      }
    }

After the modification is completed, execute: wq exits

4. Execute commands to create a kubernetes network

ansible-playbook -i inventory/your_name/hosts.ini reset.yml -vv

5. Join windows server 2019 Node

Reference resources:

https://docs.microsoft.com/en-us/virtualization/windowscontainers/kubernetes/joining-windows-workers?tabs=ManagementIP

Where, by executing the command, the parameters of the cluster are obtained

kubectl cluster-info dump > /tmp/k8s.info

Retrieval: -- cluster-cidr is <Cluster CIDR>

service-cluster-ip-range is <Service CIDR>

                "ports": [
                    {
                        "name": "dns",
                        "protocol": "UDP",
                        "port": 53,
                        "targetPort": 53
                    },
                    {
                        "name": "dns-tcp",
                        "protocol": "TCP",
                        "port": 53,
                        "targetPort": 53
                    },
                    {
                        "name": "metrics",
                        "protocol": "TCP",
                        "port": 9153,
                        "targetPort": 9153
                    }
                ],
                "selector": {
                    "k8s-app": "kube-dns"
                },
                "clusterIP": "10.96.0.10",
                "type": "ClusterIP",
                "sessionAffinity": "None"
            },

The cluster IP corresponding to kube-dns is <Kube-dns Service IP>

Finally, execute the following command, where < network mode > is overlay

.\start.ps1 -ManagementIP <Windows Node IP> -NetworkMode <network mode>  -ClusterCIDR <Cluster CIDR> -ServiceCIDR <Service CIDR> -KubeDnsServiceIP <Kube-dns Service IP> -LogDir <Log directory>

 

Posted by firepages on Thu, 03 Oct 2019 09:06:15 -0700