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

Add ability to specify annotations for the SDK service account #2317

Merged

Conversation

highlyunavailable
Copy link
Contributor

@highlyunavailable highlyunavailable commented Oct 18, 2021

What type of PR is this?

Uncomment only one /kind <> line, press enter to put that in a new line, and remove leading whitespace from that line:

/kind breaking
/kind bug
/kind cleanup
/kind documentation

/kind feature

/kind hotfix

What this PR does / Why we need it:
The gameserver SDK account commonly wants annotations, e.g. for cloud permissions for storing logs or replays. This adds the ability to map SDK accounts per namespace to maps of annotations to be added to the SDK account for the specified namespace in the Helm chart during creation. An example value from the values file for the helm chart would be:

agones:
  serviceaccount:
    sdk:
      annotations:
        gameservers:
          cloud-permission-id: 123456
        xbox:
          cloud-permission-id: 537934
gameservers:
  namespaces:
    - gameservers
    - xbox
    - staging

In this example yaml, the agones-sdk accounts in the gameservers and xbox namespaces would get annotations as follows:

name: agones-sdk
namespace: gameservers
annotations:
  cloud-permission-id: 123456
name: agones-sdk
namespace: xbox
annotations:
  cloud-permission-id: 537934

The agones-sdk service account in the staging namespace would get no annotations.

Which issue(s) this PR fixes:
N/A

Special notes for your reviewer:

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: b9c0c387-5f33-4c1f-ad3c-bc38ae5c5073

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/2317/head:pr_2317 && git checkout pr_2317
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.19.0-4a6e2f7

@@ -23,6 +23,10 @@ metadata:
chart: {{ template "agones.chart" $ }}
release: {{ $.Release.Name }}
heritage: {{ $.Release.Service }}
{{- if hasKey $.Values.agones.serviceaccount.sdk.annotations . }}
Copy link
Member

Choose a reason for hiding this comment

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

In other places we just check for existence, e.g.:

{{- if .Values.agones.allocator.service.annotations }}
  annotations:
{{ toYaml .Values.agones.allocator.service.annotations | indent 4 }}
{{- end }}

Copy link
Contributor Author

@highlyunavailable highlyunavailable Oct 18, 2021

Choose a reason for hiding this comment

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

The reason it is "hasKey" is because that checks for existence of a variable key.

Given this:

agones:
  serviceaccounts:
    sdk:
      annotations:
        gameservers-eu-central-1:
          eks.amazonaws.com/role-arn: arn:aws:iam::12345:role/IAMROLEHERE

hasKey $.Values.agones.serviceaccount.sdk.annotations . where . is gameservers-eu-central-1 is saying "does the key gameservers-eu-central-1 exist under Values.agones.serviceaccount.sdk.annotations? If yes, then put the entire map below that into annotations. As far as I know, that's the correct way to check for if .Values.agones.serviceaccount.sdk.annotations.somevariablevalue - let me know if there's a better way.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I totally missed in my initial review that this allows you to set different annotations in each namespace, which is why you are checking for keys in a map and then pulling values from the map.

I wonder if it would be worthwhile to document somewhere the expected structure here (since it is different from the other places we allow annotations). Right now, your PR is the only place people could look to see how to properly set these annotations.

@markmandel - I know we have the reference pages for the yaml files that show all of the possible options (with comments) but I don't think there is anything similar for the helm values file. As it gets more expansive, I wonder if it would make sense to better document all of the options that we are adding. WDYT?

The gameserver SDK account commonly wants annotations, e.g. for cloud
file store permissions for logs. This adds the ability to map
gameserver namespaces to maps of annotations to be added to the SDK
account for the specified namespace.
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 4a477ee9-d595-4195-a2c5-d9d8f1f840c6

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/2317/head:pr_2317 && git checkout pr_2317
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.19.0-a3b7a84

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 34904944-43ec-4cf4-8219-46875d1645d8

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/2317/head:pr_2317 && git checkout pr_2317
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.19.0-6a0128b

@roberthbailey roberthbailey added the kind/feature New features for Agones label Oct 19, 2021
@@ -23,6 +23,10 @@ metadata:
chart: {{ template "agones.chart" $ }}
release: {{ $.Release.Name }}
heritage: {{ $.Release.Service }}
{{- if hasKey $.Values.agones.serviceaccount.sdk.annotations . }}
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I totally missed in my initial review that this allows you to set different annotations in each namespace, which is why you are checking for keys in a map and then pulling values from the map.

I wonder if it would be worthwhile to document somewhere the expected structure here (since it is different from the other places we allow annotations). Right now, your PR is the only place people could look to see how to properly set these annotations.

@markmandel - I know we have the reference pages for the yaml files that show all of the possible options (with comments) but I don't think there is anything similar for the helm values file. As it gets more expansive, I wonder if it would make sense to better document all of the options that we are adding. WDYT?

@google-oss-robot
Copy link

New changes are detected. LGTM label has been removed.

@google-oss-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: highlyunavailable, 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

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: aa55fd1e-9893-4b60-963f-3096903a3754

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/2317/head:pr_2317 && git checkout pr_2317
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.19.0-7dbd38d

@roberthbailey roberthbailey merged commit 7f7a434 into googleforgames:main Oct 19, 2021
@highlyunavailable highlyunavailable deleted the add-sdk-annotations branch October 19, 2021 15:56
@roberthbailey roberthbailey added this to the 1.19.0 milestone Nov 1, 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.

4 participants