launch testing kubernetes cluster in local use Kind

The config for kind cluster settings

the expose port didn’t change when cluster launched, need prepared

 1kind: Cluster
 2apiVersion: kind.x-k8s.io/v1alpha4
 3networking:
 4  # WARNING: It is _strongly_ recommended that you keep this the default
 5  # (127.0.0.1) for security reasons. However it is possible to change this.
 6  apiServerAddress: "127.0.0.1"
 7  # This can connect to k8s from external when install kind in virtual host or cloud platform(ec2 of aws)
 8  # By default the API server listens on a random open port.
 9  # You may choose a specific port but probably don't need to in most cases.
10  # Using a random port makes it easier to spin up multiple clusters.
11  apiServerPort: 6443
12nodes:
13- role: control-plane
14  # port forward 30019 on the host to 30019 on this node
15  extraPortMappings:
16  - containerPort: 30019
17    hostPort: 30019
18    # optional: set the bind address on the host
19    # 0.0.0.0 is the current default
20    listenAddress: "0.0.0.0"
21    # optional: set the protocol to one of TCP, UDP, SCTP.
22    # TCP is the default
23    protocol: TCP
24  - containerPort: 32578
25    hostPort: 32578
26    listenAddress: "0.0.0.0"
27    protocol: TCP
28- role: worker
29- role: worker

Commands

 1# create cluster
 2kind create cluster --name local-k8s --config config.yaml
 3# view clusters
 4kind get clusters
 5# export the kubectl config to ~/.kube/config
 6kind export kubeconfig  --name local-k8s
 7# load image to cluster
 8kind load docker-image quay.io/kubevirt/virt-handler:v1.1.0-alpha.0 -n local-k8s
 9
10# attached and exec the kind nodes 
11docker exec -it local-k8s-worker bash
12# view all containerd containers
13crictl ps -a
14# prune the images to decrement space
15crictl rmi --prune
16# delete exited containers
17crictl rm $(crictl ps -a | grep Exited | awk '{print $1}')

Writen scripts to launch istio

 1#!/usr/bin/env bash
 2
 3KIND_CLUSTER_NAME="local-k8s"
 4IMAGES=('alpine:latest' 'istio/pilot:1.16.1' 'istio/proxyv2:1.16.1' 'istio/examples-bookinfo-details-v1:1.18.0' 'curlimages/curl' 'istio/examples-bookinfo-productpage-v1:1.18.0' 'istio/examples-bookinfo-ratings-v1:1.18.0' 'istio/examples-bookinfo-reviews-v1:1.18.0' 'istio/examples-bookinfo-reviews-v2:1.18.0' 'istio/examples-bookinfo-reviews-v3:1.18.0')
 5ACTIONS=('Download images' 'Load images' 'Init istio')
 6DEFAULT_ACTION="Load images"
 7
 8download_images() {
 9	for i in "${IMAGES[@]}"
10	do
11  		echo $i
12		docker pull $i
13	done
14}
15
16
17
18load_images() {
19	for i in "${IMAGES[@]}"
20	do
21		echo "load the image: $i"
22		kind load docker-image $i -n $KIND_CLUSTER_NAME
23	done
24}
25
26init_istio() {
27	istioctl install --set meshConfig.accessLogFile=/dev/stdout
28	istioctl verify-install
29	kubectl create ns apps
30	kubectl label ns apps istio-injection=enabled
31}
32
33PS3='Please enter your choice:'
34select opt in "${ACTIONS[@]}" "quit";
35do
36	case "$REPLY" in
37		1)
38		   echo "You select action $opt"
39		   download_images break;;
40		2)
41		   load_images break;;
42		3)
43		   init_istio break;;
44
45   	    $((${#ACTIONS[@]}+1)))
46            echo "Goodbye!"; exit 0;;
47		*)
48	        echo "Anythins not choice."; continue;;
49    esac
50done

Reference