Skip to content

Instantly share code, notes, and snippets.

@eth0xFEED
Created March 12, 2020 02:44
Show Gist options
  • Save eth0xFEED/995ad45c03c77c258e7a98daa9eb01cf to your computer and use it in GitHub Desktop.
Save eth0xFEED/995ad45c03c77c258e7a98daa9eb01cf to your computer and use it in GitHub Desktop.
kind k8s ipvs
#!/bin/bash
# kind cluster conf
cat > kind_conf_88698.cluster << EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
kubeadmConfigPatches:
- |
apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
metadata:
name: config
mode: ipvs
networking:
# the default CNI will not be installed
disableDefaultCNI: true
podSubnet: 192.168.0.0/16 # set to Calico's default subnet
nodes:
- role: control-plane
image: kindest/node:v1.16.4
extraPortMappings:
- containerPort: 80
hostPort: 80
- role: worker
image: kindest/node:v1.16.4
extraPortMappings:
- containerPort: 8443
hostPort: 8443
EOF
# metallb conf
cat > metal-config.yml << EOF
apiVersion: v1
kind: ConfigMap
metadata:
namespace: metallb-system
name: config
data:
config: |
address-pools:
- name: default
protocol: layer2
addresses:
- 172.17.0.240-172.17.0.250
EOF
kind delete cluster
kind create cluster --config kind_conf_88698.cluster
sleep 30
# calico CNI
kubectl apply -f https://docs.projectcalico.org/v3.8/manifests/calico.yaml
# metallb for load balancer service type
kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.8.3/manifests/metallb.yaml
kubectl apply -f metal-config.yml
sleep 20
# example echo pods
kubectl create deployment hello-server1 --image=gcr.io/google-samples/hello-app:1.0
kubectl expose deployment hello-server1 --type LoadBalancer --port 80 --target-port 8080
kubectl create deployment hello-server2 --image=gcr.io/google-samples/hello-app:1.0
kubectl expose deployment hello-server2 --type LoadBalancer --port 80 --target-port 8080
echo "TODO patch services for spec.loadBalancerSourceRanges"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment