How to push templates to Kubernetes Coder from GitLab CI/CD?

Hi all, I am trying to push my Terraform templates to my self-hosted Coder running in Kuberentes. I followed this guide: https://coder.com/docs/admin/templates/managing-templates/change-management#coder-cli This is the error I am getting:
Encountered an error running "coder templates push", see "coder templates push --help" for more information
error: get organizations: Get "https://coder.my-env.my-org.com/api/v2/users/me/organizations": dial tcp: lookup coder.my-env.my-org.com on XXX.XXX.1XX.XXX:XX: no such host
Encountered an error running "coder templates push", see "coder templates push --help" for more information
error: get organizations: Get "https://coder.my-env.my-org.com/api/v2/users/me/organizations": dial tcp: lookup coder.my-env.my-org.com on XXX.XXX.1XX.XXX:XX: no such host
I am using this command:
coder templates push --yes ${TEMPLATE_NAME} --directory ${TEMPLATE_DIR}
coder templates push --yes ${TEMPLATE_NAME} --directory ${TEMPLATE_DIR}
I appreciate this may be more of a GitLab than Coder question, but I was wondering whether someone else has accomplished something similar? To allow GitLab to connect to my Kuberentes cluster, I set up an agent in my Kubernetes cluster: https://docs.gitlab.com/ee/user/clusters/agent/install/index.html Could anyone point me in the wrong direction? Any help would be much appreciated!
Change Management - Coder Docs
Learn about template change management and versioning
From An unknown user
From An unknown user
9 Replies
Codercord
Codercord2w ago
<#1293964911877160970>
Category
Help needed
Product
Coder OSS (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
Karan
Karan2w ago
Sorry, it looks like my description disappeared. Retyping... Hi all, We are running Coder self-hosted in our Kubernetes cluster. I would like to push templates from GitLab CI/CD to Coder: https://coder.com/docs/admin/templates/managing-templates/change-management#coder-cli. I followed this approach using the Coder CLI where I am using an API token. This is the error message I'm seeing:
Encountered an error running "coder templates push", see "coder templates push --help" for more information
error: get organizations: Get "https://coder.my-env.my-org.com/api/v2/users/me/organizations": dial tcp: lookup coder.my-env.my-org.com on XXX.XXX.XXX.XXX:XX: no such host
Encountered an error running "coder templates push", see "coder templates push --help" for more information
error: get organizations: Get "https://coder.my-env.my-org.com/api/v2/users/me/organizations": dial tcp: lookup coder.my-env.my-org.com on XXX.XXX.XXX.XXX:XX: no such host
I set up my GitLab (using gitlab.com, not self-hosted) to talk to Kubernetes via an agent I installed in my cluster (following these instructions: https://docs.gitlab.com/ee/user/clusters/agent/install/index.html) Has anyone else tried to accomplish the same thing? If so, any pointers would be much appreciated!
Atif
Atif2w ago
Looks like a bug with Coder CLI. Could you try to get your org name or uuid for the default org with https://${CODER_URL}/api/v2/organizations and then Can you try coder templates push --yes ${TEMPLATE_NAME} --directory ${TEMPLATE_DIR} --org ${ORG_UUID} or ${ORG_NAME}
Karan
Karan2w ago
Thanks, Atif.
Could you try to get your org name or uuid for the default org with https://${CODER_URL}/api/v2/organizations
I have tried this:
# Example request using curl
curl -X GET https://coder.myenv.myorg.com/api/v2/organizations \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: redacted'
# Example request using curl
curl -X GET https://coder.myenv.myorg.com/api/v2/organizations \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: redacted'
But I don't get back a 405. It looks like it's expecting POST instead of GET I am looking at this endpoint section in your API reference: https://coder.com/docs/reference/api/organizations#code-samples-2
Atif
Atif2w ago
@Karan you can directly append this to your URL in browser and will get a json response.
Karan
Karan2w ago
@Atif , I get a 405 in my browser also:
No description
Atif
Atif2w ago
What about https://coder.example.com/api/v2/organizations/default ?
Karan
Karan2w ago
@Atif , that URL doesn't work for me:
No description
Atif
Atif2w ago
YOu need to replace the coder.example.com with your coder deployment URL
Want results from more Discord servers?
Add your server