Skip to content

Instantly share code, notes, and snippets.

@simonswine
Last active July 19, 2016 10:40
Show Gist options
  • Select an option

  • Save simonswine/cba39ab8d74eb4a7e4f7a1c0347ead23 to your computer and use it in GitHub Desktop.

Select an option

Save simonswine/cba39ab8d74eb4a7e4f7a1c0347ead23 to your computer and use it in GitHub Desktop.
Slingshot provisions kubernetes & flocker

Instructions

Create a flocker enabled cluster

slingshot cluster create \
  -f - \
  -I jetstack/slingshot-ip-terraform-aws-coreos:0.1 \
  -C jetstack/slingshot-cp-ansible-k8s-coreos:flocker-0.1 \
 christian-flocker <<EOF
custom:
  aws_access_key: XX
  aws_region: eu-west-1
  aws_secret_key: YY
  aws_zones: eu-west-1a
  flocker_enabled: true
general:
  cluster:
    kubernetes:
      version: 1.3.2
EOF

Wait for pods to come alive

slingshot cluster kubectl christian-flocker get pods --all-namespaces -w | grep flocker

Check status of Flocker and create first volume test1

slingshot cluster ssh christian-flocker master
core@ip-172-20-130-156 ~ $ sudo -i
ip-172-20-130-156 ~ # flockerctl status
SERVER     ADDRESS
4717f795   172.20.129.239
e4443e41   172.20.129.240

ip-172-20-130-156 ~ # flockerctl create -m name=test1 -s 10G --node=4717f795
ip-172-20-130-156 ~ # flockerctl list
DATASET                                SIZE     METADATA     STATUS     SERVER
63fd4642-2468-4cb9-b9b7-0fe16244a086   10.00G   name=test1   detached   4717f795 (172.20.129.239)

Create an example pod

volume.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: flocker-test1
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  flocker:
    datasetName: test1

slingshot cluster kubectl christian-flocker create -f volume.yaml

pod.yaml

apiVersion: v1
kind: Pod
metadata:
  name: test1
spec:
  containers:
    - name: test
      image: busybox
      command:
      - sleep
      args:
      - "36000"
      volumeMounts:
        - mountPath: /data
          name: data
  volumes:
    - name: data
      persistentVolumeClaim:
        claimName: test1
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: test1
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi

slingshot cluster kubectl christian-flocker create -f pod.yaml

access the pod

slingshot cluster kubectl christian-flocker exec -t -i test1 /bin/sh  
/ # df -h /data/
Filesystem                Size      Used Available Use% Mounted on
/dev/xvdf                 9.7G     22.5M      9.2G   0% /data
/ # ls -l /data
total 16
-rw-r--r--    1 root     root             0 Jul 19 10:02 EBS
-rw-r--r--    1 root     root             0 Jul 19 10:02 in
drwx------    2 root     root         16384 Jul 19 09:59 lost+found
-rw-r--r--    1 root     root             0 Jul 19 10:02 my-persistent-volume
/ # 

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