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

expose Helm chart values for custom certs #2367

Merged
merged 9 commits into from
Nov 16, 2021

Conversation

rahil-p
Copy link
Contributor

@rahil-p rahil-p commented Nov 11, 2021

What type of PR is this?

/kind feature

What this PR does:

This PR provides a convenient alternative for installing Agones with custom certificates. Instead of having to pull and modify the contents of the chart, custom certificates may be passed in as values:

helm install my-release agones/agones \
  --set agones.allocator.generateTLS=false \
  --set-file agones.allocator.tlsCert=mydir/tls.crt \ # or --set agones.allocator.tlsCert="$(cat mydir/tls.crt)"
  --set-file agones.allocator.tlsKey=mydir/tls.key \
  --set-file "agones.allocator.clientCAs.my-ca\.crt"=mydir/ca.crt

Which issue(s) this PR fixes:

Closes #2364

Special notes for your reviewer:

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: a2526e4b-474c-4dff-8e33-aba4a46ca17d

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@@ -38,7 +38,7 @@ spec:
{{- if .Values.agones.controller.generateTLS }}
caBundle: {{ b64enc $ca.Cert }}
{{- else }}
caBundle: {{ .Files.Get "certs/server.crt" | b64enc }}
caBundle: {{ default (.Files.Get "certs/server.crt") .Values.agones.controller.tlsCert | b64enc }}
Copy link
Member

Choose a reason for hiding this comment

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

Would it work to put "certs/server.crt" into values.yaml and just use the new variable here?

From https://helm.sh/docs/chart_template_guide/functions_and_pipelines/:

In an actual chart, all static default values should live in the values.yaml, and should not be repeated using the default command (otherwise they would be redundant).

I'm not particularly familiar with the --set-file option, but it looks like if the new parameter is a file name and we keep the .Files.Get here referencing the variable, then it might work (but using the --set flag instead of --set-file because you wouldn't pass the file contents into the variable).

Copy link
Contributor Author

@rahil-p rahil-p Nov 13, 2021

Choose a reason for hiding this comment

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

The new parameter expects the file's contents. The --set-file option will set a value to the contents of the file at the provided path - it's equivalent to --set value="$(cat value.txt)".

The idea behind the new parameter is to allow the user to pass the certificate directly as a value. When the value isn't provided, .Files.Get will be used as a fallback to read the file from the certs directory. I included this so that the old way of passing in certificates (i.e. modifying the files in certs) continues to be supported.

That said, I think it could simplify things to remove the fallback and simply expect the value to be passed.

Let me know if that makes sense and if you'd like to see any changes.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 2b9e695b-57ec-48ad-8385-2385f6cd0ee4

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2367/head:pr_2367 && git checkout pr_2367
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.19.0-adbfa06

@google-oss-prow google-oss-prow bot added size/M and removed size/S labels Nov 13, 2021
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: b02fc29b-2039-4f29-9177-a364703fa5af

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2367/head:pr_2367 && git checkout pr_2367
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.19.0-28f5dc6

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 5db5082a-0652-435b-bdf3-e6611cdb0db4

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: d3c14421-450a-49dc-96b1-1d5b5a871887

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@rahil-p
Copy link
Contributor Author

rahil-p commented Nov 13, 2021

I pushed a commit that removes reading in defaults from the certs directory. This simplifies the template. It also should provide some security in case of a user failing to pass in their own certificate - instead of silently falling back on the repository certificate, the server will log an error and exit after failing to load empty credentials.

This is breaking for releases that disable allocator.generateTLS or controller.generateTLS. If this isn't the right call, let me know and I'll revert it.

Edit: I updated the Makefile to pass in the chart certificates when generating install/yaml/install.yaml (the resulting file matches upstream).

@roberthbailey
Copy link
Member

I like these changes, but I'm on the fence about whether this will break too many folks.

@markmandel - WDYT?

@markmandel
Copy link
Collaborator

🤔 I'm on the fence with the breaking change as well. I feel like not many people use a custom certs directory (I'm actually not sure how you would do so to be honest, I assume you would have to grab the chart source, and run it locally???)

But it's hard to judge impact. Maybe we should have this PR merge with the non-breaking behaviour for now, and file an issue for the breaking change, and see if anyone objects?

@rahil-p
Copy link
Contributor Author

rahil-p commented Nov 16, 2021

I'd guess that workflow is the most common - it would probably look something like this during deployment:

helm pull agones/agones --untar
cp -TR my-certs/ agones/certs/
helm install my-release agones --values overrides.yaml

I think a new issue is a good call - it could benefit from some more discussion.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: ec6d99bc-16ae-410c-ba83-c3e0fd66431a

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@markmandel
Copy link
Collaborator

Flake in TestAutoscalerBasicFunctions

@markmandel
Copy link
Collaborator

@roberthbailey you've been tracking this more closely than I have. If you are happy with this PR, I'm happy to squeeze this in before RC today.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: bedddd62-418d-4a35-84af-0908b485f07b

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2367/head:pr_2367 && git checkout pr_2367
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.19.0-3ace450

@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rahil-p, roberthbailey

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@roberthbailey roberthbailey merged commit dd6d188 into googleforgames:main Nov 16, 2021
@SaitejaTamma SaitejaTamma added this to the 1.19.0 milestone Nov 16, 2021
@SaitejaTamma SaitejaTamma added the kind/feature New features for Agones label Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

allow passing certificates as values instead of files in the Helm chart
5 participants