Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[installer] Add custom CA secret support #9082

Merged
merged 1 commit into from
Apr 11, 2022
Merged

[installer] Add custom CA secret support #9082

merged 1 commit into from
Apr 11, 2022

Conversation

csweichel
Copy link
Contributor

@csweichel csweichel commented Apr 1, 2022

Description

Adds custom CA cert support to the installer. When specified, the CA certs are mounted into server, image-builder and ws-daemon.

Related Issue(s)

Fixes #9077

How to test

(proper test is to install Gitpod on a cluster trying to talk to a Docker registry and SCM which use custom certs).

# produce new config
installer init > cfg.yaml

# set required values
yq write -i config.yaml domain foobar.com
yq write -i config.yaml customCACert.kind secret
yq write -i config.yaml customCACert.name custom-ca-cert

# validate cluster (should fail)
installer validate cluster --config config.yaml # reports missing secret

# produce secret and validate (should succeed)
openssl genrsa -out ca.crt 2048
kubectl create secret generic custom-ca-certs --from-file=ca.crt=ca.crt
installer validate cluster --config config.yaml

# render
installer render --config config.yaml > objs.yaml

# make sure we got the certs rendered in
grep -B 5 objs.yaml custom-ca-certs

Release Notes

Add custom CA cert support to Gitpod services

@csweichel csweichel marked this pull request as ready for review April 4, 2022 08:52
@csweichel csweichel requested review from a team April 4, 2022 08:52
@github-actions github-actions bot added team: delivery Issue belongs to the self-hosted team team: webapp Issue belongs to the WebApp team team: workspace Issue belongs to the Workspace team labels Apr 4, 2022
@@ -64,3 +64,41 @@ func InternalCAContainer(ctx *RenderContext, mod ...func(*corev1.Container)) *co

return res
}

// CustomCACertVolume produces the objects required to mount custom CA certificates
func CustomCACertVolume(ctx *RenderContext) (vol *corev1.Volume, mnt *corev1.VolumeMount, env *corev1.EnvVar, ok bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Would it make sense to have the return values in a wrapper struct

@princerachit
Copy link
Contributor

@csweichel I think something is missing in the test description around yq. Are you using the default shipped version of yq with workspace full?

I believe cfg.yaml and config.yaml are the same files. And is the write keyword in yq write -i config.yaml domain foobar.com command supposed to be there? It is failing for me.

@csweichel
Copy link
Contributor Author

@csweichel I think something is missing in the test description around yq. Are you using the default shipped version of yq with workspace full?

Yes. I just used yq as it was available in my workspace on this branch.

I believe cfg.yaml and config.yaml are the same files.

Yep, fixed it in the description.

And is the write keyword in yq write -i config.yaml domain foobar.com command supposed to be there? It is failing for me.

AFAIK there are two incompatible versions of yq going 'round. I just used the yq as I found it in the workspace on this branch.

Copy link
Contributor

@corneliusludmann corneliusludmann left a comment

Choose a reason for hiding this comment

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

looks good 👍 🛹

@easyCZ
Copy link
Member

easyCZ commented Apr 7, 2022

When running through the test steps, it fails for me on:

./installer validate cluster --config config.yaml
{
  "status": "ERROR",
  "items": [
    ...,
    {
      "name": "custom-ca-cert is present and valid",
      "description": "ensures the custom-ca-cert secret is present and contains the required data",
      "status": "ERROR",
      "errors": [
        {
          "message": "secret custom-ca-cert not found",
          "type": "ERROR"
        }
      ]
    }
  ]
}

My setup:

  • Compiled installer on this branch
  • Ran the steps
  • kubectl secret create failed because the secret already existed in the default configured kubens, but I could retrieve it

@csweichel
Copy link
Contributor Author

csweichel commented Apr 7, 2022

@easyCZ that's a UX bug in the installer. The installer requires users to pass the namespace explicitly, i.e. ./installer validate cluster -n staging-cw-fix-9077 --config config.yaml works.

@corneliusludmann @lucasvaltl do we have an issue for this already?

@iamulya
Copy link

iamulya commented Apr 8, 2022

(proper test is to install Gitpod on a cluster trying to talk to a Docker registry and SCM which use custom certs).

@csweichel Doesn't the workspace pod configuration have to be changed/updated as well so that git inside workspace can talk to an SCM with custom CA?

@csweichel
Copy link
Contributor Author

(proper test is to install Gitpod on a cluster trying to talk to a Docker registry and SCM which use custom certs).

@csweichel Doesn't the workspace pod configuration have to be changed/updated as well so that git inside workspace can talk to an SCM with custom CA?

Yes. That will be a follow up PR. We already have the corresponding support in ws-manager. All that's missing is a config change.

@roboquat roboquat merged commit f273856 into main Apr 11, 2022
@roboquat roboquat deleted the cw/fix-9077 branch April 11, 2022 17:09
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed: workspace Workspace team change is running in production labels Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed: workspace Workspace team change is running in production release-note size/L team: delivery Issue belongs to the self-hosted team team: webapp Issue belongs to the WebApp team team: workspace Issue belongs to the Workspace team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add CA cert secret to the installer
6 participants