Hi all,
I have Gitlab CE 14.10.5 self managed .
I have 2 k8s clusters , for ex: k8sclusterdev & k8sclusterprod
I have 2 project A1 & A2 in group A , each project has 2 branches , for ex : dev & prod
In project A1 , branch dev , I have file .gitlab/agents/k8sclusterdev-agent/config.yaml as below
ci_access:
groups:
- id: groupA
I registered agent successfully.
In project A1 & A2 , branch dev , I have .gitlab-ci.yaml job deploy_k8s as below
script:
- kubectl config get-contexts
- kubectl config use-context groupA/projectA1:k8sclusterdev-agent
They works fine, cicd job at project A1 & A2 branch dev can find agent , get kubectl context.
I want to register another agent so project A1 & A2 branch prod can be deploy on k8sclusterprod.
In project A1 & A2 , branch prod , I have .gitlab-ci.yaml job deploy_k8s as below
script:
- kubectl config get-contexts
- kubectl config use-context groupA/projectA1:k8sclusterprod-agent
I know that I have to create a new file .gitlab/agents/k8sclusterprod-agent/config.yaml and register it but which project should I put this file ?
I tried put it in project A1 or A2 branch prod, registered it successfully but online project A1 or A2 can use it , the remain one cannot find it, agent is not shared between projects in same group
Project that has it will find it like below
$ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
groupA/projectA1:k8sclusterdev-agent gitlab agent:51
groupA/projectA2:k8sclusterprod-agent gitlab agent:60
$ kubectl config use-context groupA/projectA2:k8sclusterprod-agent
Switched to context groupA/projectA2:k8sclusterprod-agent
The remain one cannot find it
$ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
$ kubectl config use-context groupA/projectA2:k8sclusterprod-agent
error: no context exists with the name: groupA/projectA2:k8sclusterprod-agent
Please give me some advice , thank you very much.