Skip to content

Instantly share code, notes, and snippets.

@rootfs
Last active December 17, 2015 22:22
Show Gist options
  • Save rootfs/e7fddc73a737ec64b530 to your computer and use it in GitHub Desktop.
Save rootfs/e7fddc73a737ec64b530 to your computer and use it in GitHub Desktop.
kubernetes on azure

Azure Image

I use OpenLogic 7.1

Prerequisite

yum install -y git golang cifs-utils etcd docker-io
systemctl enable docker
systemctl start docker

Get my git repo

git clone https://github.com/rootfs/kubernetes
cd kubernetes
git checkout azure

Build Kuberentes

make

Run a single node Kubernetes cluster

./hack/local-up-cluster.sh

If all is well, you are expecting these message:

To start using your cluster, open up another terminal/tab and run:

  cluster/kubectl.sh config set-cluster local --server=http://127.0.0.1:8080 --insecure-skip-tls-verify=true
  cluster/kubectl.sh config set-context local --cluster=local
  cluster/kubectl.sh config use-context local
  cluster/kubectl.sh

Then on another console, cd to your kubernetes direcotry and run:

  cluster/kubectl.sh config set-cluster local --server=http://127.0.0.1:8080 --insecure-skip-tls-verify=true
  cluster/kubectl.sh config set-context local --cluster=local
  cluster/kubectl.sh config use-context local
  cluster/kubectl.sh

Create Azure File share

Create the azure-key.yaml

The azure-key.yaml is like the following

apiVersion: v1
kind: Secret
metadata:
  name: azure-key
type: Opague
data:
  key: ckN1ZVU4L21FdklXOVhEYm0rbFkrMDhhZjdUeVFhSkhRV3h0UHFBcUFGSnBGdWoyajVDb0dxUHpTR3Y4VFZNZXdpNytFMFNMZmJ3YzN5V2xzVHB6YXc9PQ==

The value of the above key is base64 encoded of your azure storage accoutnt key :

echo -n your_azure_storage_account_key |base64

Create a Pod called azure.yaml that uses Azure file storage

Here is my Pod that runs a container and mount a Azure file service:

apiVersion: v1
kind: ReplicationController
metadata:
  labels:
    name: web
  name: web
spec:
  replicas: 1
  selector:
    name: web-rc
  template:
    metadata:
      labels:
        name: web-rc
    spec:
      restartPolicy: Always
      containers:
        - image: tutum/apache-php
          name: php
          ports:
            - containerPort: 80
              name: web-port
          volumeMounts:
            - name: azure-vol
              mountPath: /var/lib/www
      volumes:
        - name: azure-vol
          azureFile:
            accountName: "rootfs"
            keyName: "azure-key"
            shareName: "kube"
            readOnly: false

Please replace accountName with your Azure storage account name

Run kubectl to provision key and container:

On your second terminal that runs the cluster/kubectl.sh command, do the following:

# ./cluster/kubectl.sh create -f azure-key.yaml 

You should expect:

secret "azure-key" created

Then

# ./cluster/kubectl.sh create -f azure.yaml 

You should expect:

replicationcontroller "web" created

Verify SMB is mounted

If all is well, you should see success message from ./cluster/kubectl.sh describe pod . You can check from mount |grep cifs to see your SMB share is mounted.

Otherwise, please send me the output of ./cluster/kubectl.sh describe pod

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