docs

Deploy the first microservice

Deploying a basic microservice to a cluster managed by Plural

Overview

Now that you have a few clusters up, you'll likely want to start deploying real workloads into them. This will show you a relatively basic use case with an example repo we've created here.

You will:

  • add a new Git repository to your Plural Console
  • deploy a service to a workload cluster with a Git-hosted Helm chart.

It's worth noting that you can put the Helm chart in any repo; it doesn't have to be the application repo. You can also create your own Helm repository using OCI or GitHub Pages, and source charts from there.

Add the Application's Git Repository

To deploy anything, you need to have a repository to source YAML manifests from. We'll use a basic Git repository, which you can add by writing to bootstrap/repositories/cd-demo.yaml:

yaml
apiVersion: deployments.plural.sh/v1alpha1
kind: GitRepository
metadata:
  name: cd-demo
spec:
  url: https://github.com/pluralsh/plrl-cd-demo.git

The example repo is public. If yours requires authentication, you can backfill the auth information in the UI, or a simple way to check it all into Git is to reference an SCMConnection that can provide repository read permissions, like so:

yaml
apiVersion: deployments.plural.sh/v1alpha1
kind: GitRepository
metadata:
  name: cd-demo
spec:
  url: https://github.com/pluralsh/plrl-cd-demo.git
  scmConnectionRef:
    name: plural
    namespace: infra

Add a ServiceDeployment to point to that Git Repository

You'll also want to register a new service deployment for this cd-demo repository, which can be done by writing to bootstrap/cd-demo/dev.yaml:

yaml
apiVersion: deployments.plural.sh/v1alpha1
kind: ServiceDeployment
metadata:
  name: cd-demo-dev
  namespace: infra
spec:
  namespace: cd-demo
  git:
    folder: helm # this is where the helm chart is located in the git repository
    ref: main
  repositoryRef:
    kind: GitRepository
    name: cd-demo
    namespace: infra
  helm: # the /helm folder is a working helm chart, so we can optionally add helm values overrides in line and our deployment operator will respect it.
    values:
      image:
        repository: ghcr.io/pluralsh/plrl-cd-test
        tag: latest # VERSION
  clusterRef:
    kind: Cluster
    name: YOUR_DEV_CLUSTER_NAME # replace this with whatever you might have named your dev cluster
    namespace: infra

Push to Deploy

We registered all these manifests under the root bootstrap folder, which a plural up-derived management cluster listens to by default, so all you should need to do is either:

git commit -m "setup example microservice"
git push

or create a PR, approve it, and merge to have this new service deploy.