Skip to content

New way provision of provision has been introduced. #32

Merged
adskyiproger merged 4 commits intodevelopfrom
k8s-provision
Aug 6, 2025
Merged

New way provision of provision has been introduced. #32
adskyiproger merged 4 commits intodevelopfrom
k8s-provision

Conversation

@alsmk
Copy link
Contributor

@alsmk alsmk commented Jul 24, 2025

Addressed issues:

  • Add "Message of the day" warning SSH users that they are operating in a production environment #6361
  • Kubernetes: Build provision workflow #9137

Implementation checklist:

  • A new environment has been created with name test-e2e
  • A new inventory file has been created with the same name of corresponding env
  • Filtered ansible taks. Added some new. Deleted which are not neccessary
  • Introduced new playbook for k8s-cluster setup
  • Github secret has been added with name ssh-key
  • Introduced a new workflow which will provision the entire cluster with some others setup
  • Ran the workflow , Test the cluster working correctly
  • Deploy OpenCRVS on the new cluster

Test results:

Test on clean environment:

Final notes:

  • List of required secrets:
    • ENCRYPTION_KEY, key to encrypt /data filesystem
    • K8S_RUNNER_TOKEN, token for github self-hosted runner
    • SSH_KEY, ssh key for provision workflow. Note, we have a plans to avoid direct connection from github to OpenCRVS servers (VMs)
    • DISK_SPACE (variable), /data/ partition size
    • DOMAIN (variable), public domain
  • Optimize tags, not all ansible tags are needed

@alsmk alsmk self-assigned this Jul 24, 2025
- name: Setup Kubernetes Cluster
hosts: all
gather_facts: yes
vars:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets store variables to group_vars


- name: Initialize Kubernetes Master
hosts: master
vars:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Store to group vars

shell: sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg /tmp/kubernetes.key

- name: Add Kubernetes APT repository
shell: echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/{{ kubernetes_version }}/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if /etc/apt/sources.list.d/kubernetes.list exists?

@@ -0,0 +1,76 @@
---
- name: Install Tigera Operator
shell: kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/{{ calico_version }}/manifests/tigera-operator.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it

KUBECONFIG: /home/provision/.kube/config
register: calico_result
failed_when: calico_result.rc != 0 and "already exists" not in calico_result.stderr

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adskyiproger adskyiproger force-pushed the k8s-provision branch 2 times, most recently from 3241eeb to fee3a8b Compare August 1, 2025 13:03
Copy link
Contributor

@euanmillar euanmillar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adskyiproger @rikukissa if I am understanding this correctly, then the previous provision and deploy process is entirely replaced by Kubernetes in this repo. I thought that the strategy for this repo would be to maintain existing Docker Swarm deployment and provisioning whilst providing Kubernetes in parallel. We would maintian both until such time as we were confident that one could be replaced. Therefore I thought that there would be some sub folders and duplication e.g. workflows/k8s_provision.yml infrastructure/swarm, infrastructure/k8s

@rikukissa
Copy link
Member

@euanmillar That was the original idea, but we quickly realised templating Docker Swarm isn’t worth it. It’s much less work to keep the current infrastructure setup in the country config and continue developing it there, while developing the Kubernetes setup here and making it configurable from the start.

@adskyiproger
Copy link
Contributor

@euanmillar , Initial goal was to keep both solutions in the same repository. One repository to maintain will also work and there is an example in e2e repository. We have 2 deployment scripts coexisting (swarm, k8s).
Kubernetes solution is build using minimal set of tools (ansible, helm), you may find Tiltfile, but it will be hidden temporary in documentation.

Countryconfig template has few pitfalls that make moving infrastructure for docker swarm very tricky:

Since we need to refactor all logic for kubernetes, it would be easier to maintain and keep code clean in separate repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants