Skip to content

Instantly share code, notes, and snippets.

@praseodym
Created March 23, 2020 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save praseodym/842ab37c6a716926ef0d8e87de1a1eaa to your computer and use it in GitHub Desktop.
Save praseodym/842ab37c6a716926ef0d8e87de1a1eaa to your computer and use it in GitHub Desktop.
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
- role: worker
#!/bin/bash
set -euxo pipefail
kind create cluster --config kind-config.yaml
kubectl create ns metallb-system
kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.9.2/manifests/metallb.yaml
kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"
kubectl apply -f metallb-config.yaml
kubectl apply -f nginx.yaml
kubectl wait --for=condition=Available --timeout=120s deploy/nginx
kubectl get events | grep service/nginx
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
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: nginx
name: nginx
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx
name: nginx
---
apiVersion: v1
kind: Service
metadata:
name: nginx-a
annotations:
metallb.universe.tf/allow-shared-ip: secret
spec:
ports:
- port: 80
targetPort: 80
selector:
app: nginx
type: LoadBalancer
externalTrafficPolicy: Local
loadBalancerIP: 172.17.0.240
---
apiVersion: v1
kind: Service
metadata:
name: nginx-b
annotations:
metallb.universe.tf/allow-shared-ip: secret
spec:
ports:
- port: 8080
targetPort: 80
selector:
app: nginx
type: LoadBalancer
externalTrafficPolicy: Local
loadBalancerIP: 172.17.0.240
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment