Skip to content

Instantly share code, notes, and snippets.

@xtophs
Last active August 15, 2018 18:35
Show Gist options
  • Save xtophs/efcd0c6e75bffd366b1e064c6b6fa294 to your computer and use it in GitHub Desktop.
Save xtophs/efcd0c6e75bffd366b1e064c6b6fa294 to your computer and use it in GitHub Desktop.
k8s cluster with standard LB

Testing Standard LB Cloud Provider

  1. Create cluster ARM template with acs-engine
acs-engine generate ...
  1. Configure template to use custom hyperkube. Edit to match
    "kubernetesHyperkubeSpec": {
      "value": "xtoph/hyperkube-amd64:xtoph-lb-0.8"
    },

  1. Create kubernetes cluster
az group create -l westus -n xtoph-k8s-slb-cluster
az group deployment create -g xtoph-k8s-slb-cluster --template-file _output/xtoph-k8s-slb-cluster/azuredeploy.json --parameters --_output/xtoph-k8s-slb-cluster/azuredeploy.parameters.json
  1. Get the master IP
ipName=$(az resource list -g xtoph-k8s-slb-cluster --resource-type Microsoft.Network/publicIPAddresses --query [0].name --out tsv) 
echo Found IP address $ipName

ipAddress=$(az resource show -g xtoph-k8s-slb-cluster --resource-type Microsoft.Network/publicIPAddresses -n $ipName --query properties.ipAddress --out tsv)
echo Address is $ipAddress
  1. Connect to the master
ssh azureuser@$ipAddress
  1. Create Standard LB Service
cat << EOF > svc-slb.yaml
apiVersion: v1
kind: Service
metadata:
  labels:
    app: hostname
  name: hostname-svc-standard
  annotations:
    service.beta.kubernetes.io/azure-load-balancer-sku: "Standard"
spec:
  ports:
  - port: 8000
    protocol: TCP
    targetPort: 8000
    name: http
  selector:
    app: hostname
  type: LoadBalancer
EOF

kubectl create -f svc-slb.yaml
  1. Create Basic LB Service
cat << EOF > svc-lb.yaml
apiVersion: v1
kind: Service
metadata:
  labels:
    app: hostname
  name: hostname-svc-basic
spec:
  ports:
  - port: 8000
    protocol: TCP
    targetPort: 8000
    name: http
  selector:
    app: hostname
  type: LoadBalancer
EOF
kubectl create -f svc-lb.yaml
  1. Create Replica Set
cat << EOF > rs.yaml
apiVersion: extensions/v1beta1
kind: ReplicaSet
metadata:
  name: hostname
spec:
  replicas: 4
  template:
    metadata:
      labels:
        app: hostname
    spec:
      containers:
        - name: hostname
          image: oguzpastirmaci/hostname
          resources:
            requests:
              cpu: 1
              memory: 100Mi
EOF
kubectl create -f rs.yaml
  1. Wait for services to have External IP addresses
kubectl get svc
  1. Test services
curl <lb-ip>:8000
curl <slb-ip>:8000
@EriksonBahr
Copy link

Thanks for the LB sku definition (service.beta.kubernetes.io/azure-load-balancer-sku: "Standard")
👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment