diff --git a/build/Makefile b/build/Makefile index 65fd44a13e..3dd3a82f17 100644 --- a/build/Makefile +++ b/build/Makefile @@ -175,6 +175,7 @@ push: push-controller-image push-agones-sdk-image push-ping-image install: ALWAYS_PULL_SIDECAR := true install: IMAGE_PULL_POLICY := "Always" install: PING_SERVICE_TYPE := "LoadBalancer" +install: CRD_CLEANUP := true install: $(ensure-build-image) install-custom-pull-secret $(DOCKER_RUN) \ helm upgrade --install --wait --namespace=agones-system\ @@ -182,6 +183,7 @@ install: $(ensure-build-image) install-custom-pull-secret --set agones.image.controller.pullPolicy=$(IMAGE_PULL_POLICY),agones.image.sdk.alwaysPull=$(ALWAYS_PULL_SIDECAR) \ --set agones.image.controller.pullSecret=$(IMAGE_PULL_SECRET) \ --set agones.ping.http.serviceType=$(PING_SERVICE_TYPE),agones.ping.udp.serviceType=$(PING_SERVICE_TYPE) \ + --set agones.crds.cleanupOnDelete=$(CRD_CLEANUP) \ agones $(mount_path)/install/helm/agones/ uninstall: $(ensure-build-image) @@ -251,7 +253,8 @@ push-agones-sdk-image: $(ensure-build-image) gen-install: $(ensure-build-image) docker run --rm $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) bash -c \ 'helm template --name=agones-manual --namespace agones-system $(mount_path)/install/helm/agones \ - --set agones.controller.generateTLS=false --set agones.enableHelmCleanupHooks=false \ + --set agones.controller.generateTLS=false \ + --set agones.crds.cleanupOnDelete=false \ > $(mount_path)/install/yaml/install.yaml' # Generate the SDK gRPC server and client code diff --git a/install/helm/README.md b/install/helm/README.md index e33606fe38..b1e4e3e4f3 100644 --- a/install/helm/README.md +++ b/install/helm/README.md @@ -84,6 +84,8 @@ The following tables lists the configurable parameters of the Agones chart and t | Parameter | Description | Default | | --------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ---------------------- | | `agones.rbacEnabled` | Creates RBAC resources. Must be set for any cluster configured with RBAC | `true` | +| `agones.crds.install` | Install the CRDs with this chart. Useful to disable if you want to subchart (since crd-install hook is broken), so you can copy the CRDs into your own chart. | `true` | +| `agones.crds.cleanupOnDelete` | Run the pre-delete hook to delete all GameServers and their backing Pods when deleting the helm chart, so that all CRDs can be removed on chart deletion | `true` | | `agones.serviceaccount.controller` | Service account name for the controller | `agones-controller` | | `agones.serviceaccount.sdk` | Service account name for the sdk | `agones-sdk` | | `agones.image.registry` | Global image registry for all images | `gcr.io/agones-images` | diff --git a/install/helm/agones/scripts/delete_crds.sh b/install/helm/agones/scripts/delete_crds.sh deleted file mode 100755 index 7cd0eb29b3..0000000000 --- a/install/helm/agones/scripts/delete_crds.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -# Copyright 2018 Google Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -kubectl delete crd fleets.stable.agones.dev -kubectl delete crd fleetallocations.stable.agones.dev -kubectl delete crd fleetautoscalers.stable.agones.dev -kubectl delete crd gameservers.stable.agones.dev -kubectl delete crd gameserversets.stable.agones.dev diff --git a/install/helm/agones/templates/crds/fleet.yaml b/install/helm/agones/templates/crds/fleet.yaml index 7df86c3c5c..a02975eff4 100644 --- a/install/helm/agones/templates/crds/fleet.yaml +++ b/install/helm/agones/templates/crds/fleet.yaml @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +{{- if .Values.agones.crds.install }} + apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: @@ -22,8 +24,6 @@ metadata: chart: {{ template "agones.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} - annotations: - "helm.sh/hook": "crd-install" spec: group: stable.agones.dev version: v1alpha1 @@ -59,3 +59,5 @@ spec: - RollingUpdate template: {{- include "gameserver.validation" . | indent 14 }} + +{{- end }} \ No newline at end of file diff --git a/install/helm/agones/templates/crds/fleetallocation.yaml b/install/helm/agones/templates/crds/fleetallocation.yaml index f7819c098b..61855baf36 100644 --- a/install/helm/agones/templates/crds/fleetallocation.yaml +++ b/install/helm/agones/templates/crds/fleetallocation.yaml @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +{{- if .Values.agones.crds.install }} + apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: @@ -22,8 +24,6 @@ metadata: chart: {{ template "agones.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} - annotations: - "helm.sh/hook": "crd-install" spec: group: stable.agones.dev version: v1alpha1 @@ -46,3 +46,5 @@ spec: minLength: 1 maxLength: 63 pattern: "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$" + +{{- end }} \ No newline at end of file diff --git a/install/helm/agones/templates/crds/fleetautoscaler.yaml b/install/helm/agones/templates/crds/fleetautoscaler.yaml index a505db19a5..4d02ff4fdb 100644 --- a/install/helm/agones/templates/crds/fleetautoscaler.yaml +++ b/install/helm/agones/templates/crds/fleetautoscaler.yaml @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +{{- if .Values.agones.crds.install }} + apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: @@ -22,8 +24,6 @@ metadata: chart: {{ template "agones.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} - annotations: - "helm.sh/hook": "crd-install" spec: group: stable.agones.dev version: v1alpha1 @@ -65,3 +65,4 @@ spec: maxReplicas: type: integer minimum: 1 +{{- end }} \ No newline at end of file diff --git a/install/helm/agones/templates/crds/gameserver.yaml b/install/helm/agones/templates/crds/gameserver.yaml index d6b827e61e..4207db02e9 100644 --- a/install/helm/agones/templates/crds/gameserver.yaml +++ b/install/helm/agones/templates/crds/gameserver.yaml @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +{{- if .Values.agones.crds.install }} + apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: @@ -22,8 +24,6 @@ metadata: chart: {{ template "agones.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} - annotations: - "helm.sh/hook": "crd-install" spec: group: stable.agones.dev version: v1alpha1 @@ -37,3 +37,5 @@ spec: validation: openAPIV3Schema: {{- include "gameserver.validation" . | indent 6 }} + +{{- end }} diff --git a/install/helm/agones/templates/crds/gameserverset.yaml b/install/helm/agones/templates/crds/gameserverset.yaml index 7296ea950f..37812cfab0 100644 --- a/install/helm/agones/templates/crds/gameserverset.yaml +++ b/install/helm/agones/templates/crds/gameserverset.yaml @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +{{- if .Values.agones.crds.install }} + apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: @@ -22,8 +24,6 @@ metadata: chart: {{ template "agones.chart" . }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} - annotations: - "helm.sh/hook": "crd-install" spec: group: stable.agones.dev version: v1alpha1 @@ -53,3 +53,4 @@ spec: - Distributed template: {{- include "gameserver.validation" . | indent 14 }} +{{- end }} \ No newline at end of file diff --git a/install/helm/agones/templates/hooks/post_delete_hook.yaml b/install/helm/agones/templates/hooks/post_delete_hook.yaml deleted file mode 100644 index 6172926f8e..0000000000 --- a/install/helm/agones/templates/hooks/post_delete_hook.yaml +++ /dev/null @@ -1,49 +0,0 @@ -{{- if .Values.agones.enableHelmCleanupHooks }} -# Copyright 2018 Google Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: batch/v1 -kind: Job -metadata: - name: "{{.Release.Name}}-delete-crds" - labels: - app.kubernetes.io/managed-by: {{.Release.Service | quote }} - app.kubernetes.io/instance: {{.Release.Name | quote }} - helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" - annotations: - "helm.sh/hook": post-delete - "helm.sh/hook-delete-policy": before-hook-creation -spec: - template: - metadata: - name: "{{.Release.Name}}-delete-crds" - labels: - app.kubernetes.io/managed-by: {{.Release.Service | quote }} - app.kubernetes.io/instance: {{.Release.Name | quote }} - helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" - spec: - serviceAccountName: helm-hook-cleanup - restartPolicy: Never - containers: - - name: post-delete-delete-crd - image: "lachlanevenson/k8s-kubectl:v1.10.9" - command: ["/bin/sh", "/scripts/delete_crds.sh"] - volumeMounts: - - name: script - mountPath: /scripts/ - volumes: - - name: script - configMap: - name: delete-crds -{{- end }} diff --git a/install/helm/agones/templates/hooks/pre_delete_hook.yaml b/install/helm/agones/templates/hooks/pre_delete_hook.yaml index 4ca99e134e..e30f248fd1 100644 --- a/install/helm/agones/templates/hooks/pre_delete_hook.yaml +++ b/install/helm/agones/templates/hooks/pre_delete_hook.yaml @@ -1,4 +1,4 @@ -{{- if .Values.agones.enableHelmCleanupHooks }} +{{- if .Values.agones.crds.cleanupOnDelete }} # Copyright 2018 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/install/helm/agones/templates/hooks/sa.yaml b/install/helm/agones/templates/hooks/sa.yaml index 0aae0590d4..f46746c677 100644 --- a/install/helm/agones/templates/hooks/sa.yaml +++ b/install/helm/agones/templates/hooks/sa.yaml @@ -1,4 +1,4 @@ -{{- if .Values.agones.enableHelmCleanupHooks }} +{{- if .Values.agones.crds.cleanupOnDelete }} # Copyright 2018 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -44,9 +44,6 @@ metadata: "helm.sh/hook-weight": "-5" "helm.sh/hook-delete-policy": before-hook-creation rules: -- apiGroups: ["apiextensions.k8s.io"] - resources: ["customresourcedefinitions"] - verbs: ["delete"] - apiGroups: ["stable.agones.dev"] resources: ["fleets", "fleetallocations", "fleetautoscalers", "gameservers", "gameserversets"] verbs: ["delete", "list" ] diff --git a/install/helm/agones/templates/hooks/scripts.yaml b/install/helm/agones/templates/hooks/scripts.yaml index b3faf388dc..45064716a5 100644 --- a/install/helm/agones/templates/hooks/scripts.yaml +++ b/install/helm/agones/templates/hooks/scripts.yaml @@ -1,4 +1,4 @@ -{{- if .Values.agones.enableHelmCleanupHooks }} +{{- if .Values.agones.crds.cleanupOnDelete }} # Copyright 2018 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,22 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -apiVersion: v1 -kind: ConfigMap -metadata: - name: delete-crds - labels: - app.kubernetes.io/managed-by: {{.Release.Service | quote }} - app.kubernetes.io/instance: {{.Release.Name | quote }} - helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}" - annotations: - "helm.sh/hook": pre-delete - "helm.sh/hook-weight": "-3" - "helm.sh/hook-delete-policy": before-hook-creation -data: - delete_crds.sh: | -{{ .Files.Get "scripts/delete_crds.sh" | indent 4 }} ---- apiVersion: v1 kind: ConfigMap metadata: diff --git a/install/helm/agones/values.yaml b/install/helm/agones/values.yaml index 0a97a563b2..f43421e144 100644 --- a/install/helm/agones/values.yaml +++ b/install/helm/agones/values.yaml @@ -16,7 +16,9 @@ agones: rbacEnabled: true - enableHelmCleanupHooks: true + crds: + install: true + cleanupOnDelete: true serviceaccount: controller: agones-controller sdk: agones-sdk diff --git a/install/yaml/install.yaml b/install/yaml/install.yaml index 761aaf8a95..706e5b7b8f 100644 --- a/install/yaml/install.yaml +++ b/install/yaml/install.yaml @@ -163,8 +163,6 @@ metadata: chart: agones-0.7.0-rc release: agones-manual heritage: Tiller - annotations: - "helm.sh/hook": "crd-install" spec: group: stable.agones.dev version: v1alpha1 @@ -303,7 +301,6 @@ spec: type: integer minimum: 1 maximum: 2147483648 - --- # Source: agones/templates/crds/fleetallocation.yaml # Copyright 2018 Google Inc. All Rights Reserved. @@ -330,8 +327,6 @@ metadata: chart: agones-0.7.0-rc release: agones-manual heritage: Tiller - annotations: - "helm.sh/hook": "crd-install" spec: group: stable.agones.dev version: v1alpha1 @@ -354,7 +349,6 @@ spec: minLength: 1 maxLength: 63 pattern: "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$" - --- # Source: agones/templates/crds/fleetautoscaler.yaml # Copyright 2018 Google Inc. All Rights Reserved. @@ -381,8 +375,6 @@ metadata: chart: agones-0.7.0-rc release: agones-manual heritage: Tiller - annotations: - "helm.sh/hook": "crd-install" spec: group: stable.agones.dev version: v1alpha1 @@ -424,7 +416,6 @@ spec: maxReplicas: type: integer minimum: 1 - --- # Source: agones/templates/crds/gameserver.yaml # Copyright 2018 Google Inc. All Rights Reserved. @@ -451,8 +442,6 @@ metadata: chart: agones-0.7.0-rc release: agones-manual heritage: Tiller - annotations: - "helm.sh/hook": "crd-install" spec: group: stable.agones.dev version: v1alpha1 @@ -596,8 +585,6 @@ metadata: chart: agones-0.7.0-rc release: agones-manual heritage: Tiller - annotations: - "helm.sh/hook": "crd-install" spec: group: stable.agones.dev version: v1alpha1 @@ -730,7 +717,6 @@ spec: type: integer minimum: 1 maximum: 2147483648 - --- # Source: agones/templates/service.yaml # Copyright 2018 Google Inc. All Rights Reserved. @@ -949,10 +935,6 @@ spec: targetPort: 8080 protocol: UDP type: LoadBalancer ---- -# Source: agones/templates/hooks/post_delete_hook.yaml - - --- # Source: agones/templates/hooks/pre_delete_hook.yaml