sudo snap install kubectl --classic
sudo snap install juju --classic
juju add-credential
juju bootstrap
(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
# 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
mkdir ~.kube
juju scp kubernetes-master/0:/home/ubuntu/config ~/.kube/config
juju add-k8s k8stest
juju add-model test k8stest
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
# 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 k8stest
juju destroy-controller ...