Create a new project

mkdir myproject
cd myproject
git init

Define which version of the Camptocamp DevOps Stack to use

You can define the version to use for: - the Gitlab CI pipeline, - the Terraform composition module, - the Kubernetes core applications to deploy.

In production system, you should always use the same version for this 3 elements, but it may be convient when testing to change the version of only one of these.

Create .gitlab-ci.yml file

cat << EOF > .gitlab-ci.yml
---
include:
  - https://raw.githubusercontent.com/camptocamp/camptocamp-devops-stack/v0.18.0/.gitlab-ci/pipeline.yaml
EOF

Create Terraform root module

Declare Camptocamp’s DevOps Stack’s Terraform’s composition module:

mkdir terraform
cat << EOF > terraform/main.tf
module "cluster" {
  source = "git::https://github.com/camptocamp/camptocamp-devops-stack.git//modules/eks-aws?ref=v0.18.0"

  cluster_name = terraform.workspace
  vpc_id       = data.aws_vpc.this.id

  worker_groups = [
    {
      instance_type        = "m5a.large"
      asg_desired_capacity = 2
      asg_max_size         = 3
    }
  ]

  repo_url        = "https://github.com/camptocamp/camptocamp-devops-stack.git"
  target_revision = "v0.18.0"
}
EOF

Gitlab CI’s pipeline requires outputs to run argocd app diff on merge requests. Declare required outputs:

cat << EOF > terraform/outputs.tf
output "argocd_auth_token" {
  sensitive = true
  value     = module.cluster.argocd_auth_token
}

output "kubeconfig" {
  sensitive = true
  value     = module.cluster.kubeconfig
}

output "repo_url" {
  value = module.cluster.repo_url
}

output "target_revision" {
  value = module.cluster.target_revision
}

output "app_of_apps_values" {
  sensitive = true
  value     = module.cluster.app_of_apps_values
}
EOF