1 of 20

CI / CD

CIS 1912

2 of 20

Housekeeping

final project proposal & example

3 of 20

HW3: Kube Config

Download kubeconfig from Drive and copy it to ~/.kube/config

tinyurl.com/cis1912-kubeconfig

4 of 20

Developer Experience

What steps are required to deploy a new version of our code?

5 of 20

Deploy Steps

  1. Make code change
  2. Test out code
  3. Build Docker image
  4. Tag Docker image
  5. Push image up to Docker Hub
  6. Modify Kube manifests with proper image tag
  7. Apply in new manifests

Idea: Build automation for these so we can focus on writing code not deploying it.

6 of 20

CI vs CD vs CD

Continuous Integration

Practice of merging in changes as frequently as possible, leveraging automated testing to ensure merges don't break functionality

Continuous Delivery

Practice of extending CI to also deploy to a staging environment

Continuous Deployment

Practice of automatically deploying if CI stages all pass

7 of 20

Git[lab] Flow

8 of 20

How does CI/CD Work?

  • At a fundamental level CI/CD is basically just fancy bash scripts that run on someone else’s computer
    • Remember the cloud?
    • RCE as a Service
  • Normally linked to a git repo such that different actions are performed under different criteria
    • Making a Pull Request, merging into master/main, etc
  • Generally configured using YAML with provider-specific configuration wrapping the actual commands you want to run

9 of 20

GitHub Actions

  • CI/CD built into GitHub
  • Consists of yaml files in .github/workflows directory of repos
  • Each file represents a workflow (distinct goal to accomplish)
  • A workflow is composed of a set of jobs (tasks to accomplish the goal of the workflow)
  • A job is composed of steps which either run commands or use 3rd party reusable components (also called Actions because otherwise it would be too easy to figure out what’s going on)
  • If you ever get lost with GitHub Actions their Workflow Syntax docs describe pretty much everything you can do with them.

10 of 20

CI/CD Demo

https://github.com/cis1912/ci-demo

(fork this repo don’t clone it)

11 of 20

GitHub Actions Example

name: Lint and Publish

on: push

jobs:

lint:

name: Run lint

runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v4

- run: |

yarn install

yarn lint

publish:

name: Publish to github package registry

runs-on: ubuntu-latest

needs: lint

steps:

- uses: actions/checkout@v4

- uses: JS-DevTools/npm-publish@v1

with:

registry: https://npm.pkg.github.com

token: ${{ secrets.GITHUB_TOKEN }}

12 of 20

GitHub Actions Example

name: Lint and Publish

on: push

jobs:

lint:

name: Run lint

runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v2

- run: |

yarn install

yarn lint

publish:

name: Publish to github package registry

runs-on: ubuntu-latest

needs: lint

steps:

- uses: actions/checkout@v2

- uses: JS-DevTools/npm-publish@v1

with:

registry: https://npm.pkg.github.com

token: ${{ secrets.GITHUB_TOKEN }}

Steps: run or uses(with)

Secrets: GitHub Actions secrets

13 of 20

Debugging CI

14 of 20

State Management

If my cluster was wiped to the ground, what steps would be required to get me back to this state?

15 of 20

GitOps

Instead of storing state in clusters after CI runs, what if we stored the state in another git repo? With GitOps, we can serialize our desired state into Git.

Now we get our favorite properties of Git:

  • Rollback
  • Discoverability
  • Reproducibility

16 of 20

GitOps with Argo

17 of 20

Where we've been

The DevOps Pipeline

18 of 20

Final Projects!

19 of 20

Fin

  • Come to office hours!
  • HW3 will be released soon
  • Work on final projects

20 of 20

Credits

Gitlab flow:

https://about.gitlab.com/solutions/gitlab-flow/

Gitops with argo:

https://nortal.com/blog/gitops-argocd/