ldc-cluster-k8s/README.md
2024-03-05 15:27:27 +01:00

2.4 KiB

Cluster K8s

Init flux agent

Install flux CLI

curl -s https://fluxcd.io/install.sh | sudo bash 

Create flux agent for staging

You need to be connected in dev-cluster-k8s by kubeconfig.

export GITLAB_TOKEN=<cluster-k8s-flux-token-api>
flux bootstrap gitlab \
--hostname=lab.s-web.fr \
--owner=ldc-web \
--repository=cluster-k8s \
--branch=deploy/staging \
--path=flux/staging \
--deploy-token-auth

Then you need to add a Kustomization resource for each root folder you want to synchronize with the cluster at the end of the file flux/staging/gotk-sync.yaml. For staging environment:

---
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
  name: namespaces
  namespace: flux-system
spec:
  interval: 1m0s
  path: ./namespaces
  prune: true
  sourceRef:
    kind: GitRepository
    name: cluster-k8s
---
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
  name: common-services
  namespace: flux-system
spec:
  interval: 1m0s
  path: ./manifests/common-services
  prune: true
  sourceRef:
    kind: GitRepository
    name: cluster-k8s

Create flux agent for production

You need to be connected in cluster-k8s by kubeconfig.

export GITLAB_TOKEN=<cluster-k8s-flux-token-api>
flux bootstrap gitlab \
--hostname=lab.s-web.fr \
--owner=ldc-web \
--repository=cluster-k8s \
--branch=deploy/production \
--path=flux/production \
--deploy-token-auth

Then the resources to add in flux/production/gotk-sync.yaml for production environment:

---
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
  name: namespaces
  namespace: flux-system
spec:
  interval: 1m0s
  path: ./namespaces
  prune: true
  sourceRef:
    kind: GitRepository
    name: cluster-k8s
---
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2
kind: Kustomization
metadata:
  name: common-services
  namespace: flux-system
spec:
  interval: 1m0s
  path: ./manifests
  prune: true
  sourceRef:
    kind: GitRepository
    name: cluster-k8s

Note that in production we follow the entire folder ./manifests to deploy services as velero or custom services for ldc web.