Skip to content

Instantly share code, notes, and snippets.

@navicore
Last active March 30, 2017 22:42
Show Gist options
  • Save navicore/5b67aba5c6c0c30f91e3c65f1e31507f to your computer and use it in GitHub Desktop.
Save navicore/5b67aba5c6c0c30f91e3c65f1e31507f to your computer and use it in GitHub Desktop.
azure cli v2 commands for acs kubernetes

AZ and ACS Tool Setup

See this.

  • make sure you have a working go env with a GO_PATH

  • cd ~/go/src and git clone git@github.com:Azure/acs-engine.git

  • make ci and deal with a bunch of dep hiccups

**note, you can skip building acs-engine above by using a docker image. use:

alias acs-engine='docker run -v pwd:/files -it navicore/acs-engine:03162017'

  • install az curl -L https://aka.ms/InstallAzureCli | bash

  • login with az az login

  • install kubectrl az acs kubernetes install-cli

Kubernetes Setup

create service principal

az ad sp create-for-rbac -n "k8s-1-sp --role="Contributor"

edit copy of examples/kubernetes.json

./acs-engine ./k8s-1.json

create resource group

az group create --name "k8s-1" --location westus

create deployment

az group deployment create --name "k8s-1" --resource-group "k8s-1" --template-file "./_output/Kubernetes-12381313/azuredeploy.json" --parameters "@./_output/Kubernetes-12381313/azuredeploy.parameters.json"

get kubectl creds (silently clobbers ~/.kube/config)

az acs kubernetes get-credentials --dns-prefix=onextent-m --location=westus

talk to kubernetes

kubectl get nodes

web ui

kubectl proxy

then kubectl proxy

Access Private Registry Images

kubectl create secret docker-registry myregistrykey --docker-email ed@onextent.com --docker-username USERNAME --docker-password PASSWORD [--docker-server SERVER]

access:

apiVersion: v1
kind: Pod
metadata:
  name: whatever
spec:
  containers:
    - name: whatever
      image: index.docker.io/DOCKER_USER/PRIVATE_REPO_NAME:latest
      imagePullPolicy: Always
      command: [ "echo", "SUCCESS" ]
  imagePullSecrets:
    - name: myregistrykey

DEMO

kubectl run nginx1 --image nginx
kubectl expose deployment nginx2 --port=80

change type to LoadBalancer

kubectl edit svc/nginx2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment