# Essential Course Notes on Cloud Native Application Architecture

A few months ago, I signed up for a [course](https://www.udacity.com/course/cloud-native-application-architecture-nanodegree--nd064) to help me understand the responsibilities of a Software Architect, and the projects mentioned in the [syllabus](https://d20vrrgs8k4bvw.cloudfront.net/documents/en-US/Cloud+Native+Application+Architecture+Nanodegree+Program+Syllabus.pdf) were exactly what I was looking for. [Refactoring a Monolith](https://github.com/udacity/nd064-c2-message-passing-projects-starter/) is the most difficult Udacity project that I've completed, so I'm making a record for myself and future students.

### Setting up the developer environment

#### Kubernetes
The project's setup instructions calls for using vagrant to create a virtual machine which automatically installs `k3s` and forwards the necessary ports for access this cluster. If you already have a local kubernetes instance installed, this process can be skipped. I already had Docker Desktop installed, which includes kubernetes, it simply needed to be [enabled](https://docs.docker.com/desktop/kubernetes/#enable-kubernetes). Once enabled, the project's deployment folder can be applied to the local cluster with ease.
> kubectl apply -f deployment/

Using an existing cluster avoids having to [managing access to multiple clusters](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/). Once the project **works**, you can use vagrant to create your VM and debug with confidence knowing that your installation was sound. Issues typically encountered involved incompatibilities between `k3s` and virtualbox OS images.


#### Skaffold

Any project that involves local kubernetes development should use [skaffold](https://skaffold.dev/). From the documentation:
> Skaffold is a command line tool that facilitates continuous development for Kubernetes-native applications. Skaffold handles the workflow for building, pushing, and deploying your application, and provides building blocks for creating CI/CD pipelines.

%[https://youtu.be/8_Ozfa7JLEs]

Near the end of your development, you can then use skaffold to push the latest images to your docker hub account. One issue I encountered was that the images pushed to docker hub had tags _other than_ `latest`. I had to include the following in my `skaffold.yaml` build section. 


```yaml
  tagPolicy:
    sha256: {}
``` 
An example of how it looks can be seen [here](https://skaffold.dev/docs/pipeline-stages/taggers/#example-5). 

**Very important**: set the **imagePullPolicy** in your deployment files to [IfNotPresent](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy). This allows your local cluster to use the images directly built by skaffold, rather than pulling them from Docker Hub.


