Skip to content

Instantly share code, notes, and snippets.

@CalvinHartwell
Last active April 4, 2019 04:29
Show Gist options
  • Save CalvinHartwell/f17998c6805fe7bdc8473e86c6444c95 to your computer and use it in GitHub Desktop.
Save CalvinHartwell/f17998c6805fe7bdc8473e86c6444c95 to your computer and use it in GitHub Desktop.
juju-k8s-caas-charms-demo.MD

Setup juju for cloud of choice

  sudo snap install kubectl --classic
  sudo snap install juju --classic 
  juju add-credential
  juju bootstrap 

Deploy CDK

  (overlay is optional, see bundle below)
  juju deploy cs:canonical-kubernetes --overlay ./k8s-aws-overlay.yaml
applications:
  aws-integrator:
    charm: cs:~containers/aws-integrator
    num_units: 1
relations:
  - ['aws-integrator', 'kubernetes-master']
  - ['aws-integrator', 'kubernetes-worker']
  juju trust aws-integrator
watch --color juju status --color 

Setup storage class:

# create a storage class using the `kubernetes.io/aws-ebs` provisioner
kubectl create -f - <<EOY
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: default
  annotations:
     storageclass.kubernetes.io/is-default-class: "true"
provisioner: kubernetes.io/aws-ebs
parameters:
  type: gp2
EOY

Demo of Operational tasks performed by Juju

# Example of adding storage to existing nodes (juju interacts with cloud provider)
juju add-storage ceph-osd/0 osd-devices=ebs,100G,1
juju add-storage ceph-osd/1 osd-devices=ebs,100G,1
juju add-storage ceph-osd/2 osd-devices=ebs,100G,1
# Example of Juju opening arbitary ports
juju run --unit kubernetes-worker/0 "open-port 8000"
juju run --unit kubernetes-worker/1 "open-port 8000"
juju run --unit kubernetes-worker/2"open-port 8000"
# Example of scaling k8s worker nodes using Juju
juju add-unit kubernetes-worker
watch --color juju status --color

Setup k8s on juju

mkdir ~.kube
juju scp kubernetes-master/0:/home/ubuntu/config ~/.kube/config
juju add-k8s k8stest
juju add-model test k8stest

Deploy MariaDB k8s charm and gitlab charm

watch --color juju status --color 
kubectl get all --all-namespaces 
juju deploy cs:~juju/mariadb-k8s
juju deploy cs:~juju/gitlab-k8s
juju relate gitlab-k8s mariadb-k8s

Access the gitlab instance:

 # expose the port, or use load-balancer provided by AWS/Azure etc. 
 # By default juju creates a service for each container, so you could modify that to NodePort and open port on each worker
 # Using command above^ in operations section...
 
 kubectl edit svc gitlab-k8s --namespace <model-name>
 
 # Replace the type ClusterIP with nodeport if you want nodeport. 

Remove k8s endpoint from juju

remove-k8s k8stest
juju destroy-controller ... 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment