Set up a KiND cluster

How to set up a KiND cluster

前期准备

Install and configure KiND

Refer to the KiND documentation to install.

If you are using Docker Desktop, verify that you have the recommended settings.

Configure and create the KiND cluster

  1. Create a file named kind-cluster-config.yaml, and paste the following:

    1. kind: Cluster
    2. apiVersion: kind.x-k8s.io/v1alpha4
    3. nodes:
    4. - role: control-plane
    5. kubeadmConfigPatches:
    6. - |
    7. kind: InitConfiguration
    8. nodeRegistration:
    9. kubeletExtraArgs:
    10. node-labels: "ingress-ready=true"
    11. extraPortMappings:
    12. - containerPort: 80
    13. hostPort: 8081
    14. protocol: TCP
    15. - containerPort: 443
    16. hostPort: 8443
    17. protocol: TCP
    18. - role: worker
    19. - role: worker

    This cluster configuration:

    • Requests KiND to spin up a Kubernetes cluster comprised of a control plane and two worker nodes.
    • Allows for future setup of ingresses.
    • Exposes container ports to the host machine.
  2. Run the kind create cluster command, providing the cluster configuration file:

    1. kind create cluster --config kind-cluster-config.yaml

    预期输出

    1. Creating cluster "kind" ...
    2. Ensuring node image (kindest/node:v1.21.1) 🖼
    3. Preparing nodes 📦 📦 📦
    4. Writing configuration 📜
    5. Starting control-plane 🕹️
    6. Installing CNI 🔌
    7. Installing StorageClass 💾
    8. Joining worker nodes 🚜
    9. Set kubectl context to "kind-kind"
    10. You can now use your cluster with:
    11. kubectl cluster-info --context kind-kind
    12. Thanks for using kind! 😊

Initialize and run Dapr

  1. Initialize Dapr in Kubernetes.

    1. dapr init --kubernetes

    Once Dapr finishes initializing, you can use its core components on the cluster.

  2. Verify the status of the Dapr components:

    1. dapr status -k

    预期输出

    1. NAME NAMESPACE HEALTHY STATUS REPLICAS VERSION AGE CREATED
    2. dapr-sentry dapr-system True Running 1 1.5.1 53s 2021-12-10 09:27.17
    3. dapr-operator dapr-system True Running 1 1.5.1 53s 2021-12-10 09:27.17
    4. dapr-sidecar-injector dapr-system True Running 1 1.5.1 53s 2021-12-10 09:27.17
    5. dapr-dashboard dapr-system True Running 1 0.9.0 53s 2021-12-10 09:27.17
    6. dapr-placement-server dapr-system True Running 1 1.5.1 52s 2021-12-10 09:27.18
  3. Forward a port to Dapr dashboard:

    1. dapr dashboard -k -p 9999
  4. Navigate to http://localhost:9999 to validate a successful setup.

Install metrics-server on the Kind Kubernetes Cluster

  1. Get metrics-server manifests

    1. wget https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
  2. Add insecure TLS parameter to the components.yaml file

    1. metadata:
    2. labels:
    3. k8s-app: metrics-server
    4. spec:
    5. containers:
    6. - args:
    7. - --cert-dir=/tmp
    8. - --secure-port=4443
    9. - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
    10. - --kubelet-use-node-status-port
    11. - --kubelet-insecure-tls <==== Add this
    12. - --metric-resolution=15s
    13. image: k8s.gcr.io/metrics-server/metrics-server:v0.6.2
    14. imagePullPolicy: IfNotPresent
    15. livenessProbe:
    16. failureThreshold: 3
    17. httpGet:
    18. path: /livez
  3. Apply modified manifest

    1. kubectl apply -f components.yaml