Deploy an app

This page helps you deploy your app from Git to one of your project's environments.

By default Cairn deploys the Kubernetes files in your repository, using an image you have already built, for example with GitHub Actions or GitLab CI. Argo CD keeps the environment in sync with those files. That is what this page covers.

Want Cairn to build the image from your source code instead? That is an opt-in feature your server administrator turns on; see Build from Git.

What your repository needs

A folder with your Kubernetes files. Cairn looks in k8s unless you choose another path. At minimum, add a Deployment and a Service that listens on port 80. Cairn points the environment's address at that Service.

your-repo/
  k8s/
    kustomization.yaml
    deployment.yaml
    service.yaml
# k8s/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - deployment.yaml
  - service.yaml
# k8s/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: shop
spec:
  selector:
    app: shop
  ports:
    - port: 80
      targetPort: 8080
# k8s/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: shop
spec:
  replicas: 1
  selector:
    matchLabels:
      app: shop
  template:
    metadata:
      labels:
        app: shop
    spec:
      securityContext:
        runAsNonRoot: true
        runAsUser: 65532
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: app
          image: ghcr.io/acme/shop:1.0.0
          ports:
            - containerPort: 8080
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop: ["ALL"]

Leave out namespace. Cairn puts each environment in its own namespace. Containers must run as a non-root user, as in the example, because project namespaces use the Kubernetes "restricted" security level. See Namespace isolation.

A working example lives in the repository at examples/sdk-demo/k8s. Push these files to your repository before you deploy.

Deploy

  1. Open your project and go to Deployments.
  2. In Deploy, choose the Environment, for example development.
  3. Choose a Branch or tag and a Commit. Leave the commit as it is to ship the newest one.
  4. If your files are not in k8s, open Advanced and enter the folder in Folder with deploy files.
  5. Select Deploy.

The progress shows each step: apply the files, wait until the app is healthy, then finish. A deploy that is not healthy within about three minutes is marked as failed, with the reason.

When it succeeds, open the environment's address from Environments on the same page.

Roll back or redeploy

  • History lists every deploy. Select Rollback to go back to an earlier one.
  • Releases lists your repository's tagged releases. Select Deploy next to one to ship it.

Preview a branch

A preview environment gives a branch its own short-lived address, so others can try a change before it is merged. See Preview environments.

Details

  • Which commit is used. An explicit branch or commit wins. Otherwise the project's Git revision setting is used, then the repository's default branch. See Branches and Argo CD.
  • Sync and refresh. The project's Argo CD panel shows sync and health, and lets you refresh or sync an environment by hand.
  • Logs and metrics. Once your app runs, see Monitoring and alerts.
  • Before going live. Work through the Production checklist.