Deploy OSM on AWS

For using an AWS CDK for our OSM deployment we will need to follow these steps:

Create an AWS controller with juju:

juju bootstrap aws aws-k8s

We’ll deploy Kubernetes using the ‘kubernetes-core’ bundle, which will give us a minimalist cluster (Subsitute kubernetes-core with kubernetes for a complete Kubernetes). We’ll add the integrator charm to the mix by means of an overlay bundle that we’ll store in file k8s-aws-overlay.yaml:

applications:
  aws-integrator:
    charm: cs:~containers/aws-integrator
    num_units: 1
relations:
  - ['aws-integrator', 'kubernetes-master']
  - ['aws-integrator', 'kubernetes-worker']

We can now deploy the cluster like so:

juju deploy charmed-kubernetes --overlay k8s-aws-overlay.yaml
juju trust aws-integrator

Now we have to grab the config file from the kubernetes-master pod and install kubectl:

mkdir ~/.kube
juju scp kubernetes-master/0:config ~/.kube/config
sudo snap install kubectl --classic

Once kubectl is installed we will have to setup storage with the following script:

#!/bin/bash

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

# create a persistent volume claim using that storage class
kubectl create -f - <<EOY
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: testclaim
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 100Mi
  storageClassName: ebs-1
EOY

# create the busybox pod with a volume using that PVC:
kubectl create -f - <<EOY
apiVersion: v1
kind: Pod
metadata:
  name: busybox
  namespace: default
spec:
  containers:
    - image: busybox
      command:
        - sleep
        - "3600"
      imagePullPolicy: IfNotPresent
      name: busybox
      volumeMounts:
        - mountPath: "/pv"
          name: testvolume
  restartPolicy: Always
  volumes:
    - name: testvolume
      persistentVolumeClaim:
        claimName: testclaim
EOY

Once the storage is setup we can add-k8s and bootstrap a controller on it, in we will put our aws region on which the k8s is deployed.

cat .kube/config | juju add-k8s k8s-cloud --local --region=aws/<region>
juju bootstrap k8s-cloud

Once the bootstrap has been executed we can continue with the rest of the installation steps for OSM like usual.

Install OSM in AWS [WIP]

Once the juju bootstrap k8s-cloud command has been successfully completed, the steps to install OSM on top of that are very similar to the ones here: https://discourse.jujucharms.com/t/first-steps-with-the-canonical-distribution-of-open-source-mano.

juju add-model osm
juju create-storage-pool operator-storage kubernetes
juju create-storage-pool osm-pv kubernetes
juju create-storage-pool packages-pv kubernetes
juju deploy cs:~charmed-osm/osm-ha

On AWS, should the storage-class still be microk8s-hostpath?