Skip to content

Commit

Permalink
wip: Add helm configuration for the operator
Browse files Browse the repository at this point in the history
  • Loading branch information
hessjcg committed Oct 26, 2023
1 parent 69e57d0 commit 0869192
Show file tree
Hide file tree
Showing 35 changed files with 2,897 additions and 257 deletions.
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,31 @@ installer/install.sh: ## Build install shell script to deploy the operator
sed 's/__VERSION__/v$(VERSION)/g' | \
sed 's/__CERT_MANAGER_VERSION__/$(CERT_MANAGER_VERSION)/g' > $@

##
# Update helm chart
.PHONY: helm_generate
helm_generate: helm installer/cloud-sql-proxy-operator.yaml bin/install_to_helm
bin/install_to_helm \
-installYaml=installer/cloud-sql-proxy-operator.yaml \
-operatorChartDir=helm/cloud-sql-operator
-crdChartDir=helm/cloud-sql-operator-crds

.PHONY: helm_e2e_build_deploy
helm_e2e_build_deploy: helm e2e_image_push e2e_cert_manager_deploy helm_e2e_install

.PHONY: helm_e2e_install
helm_e2e_install: helm
KUBECONFIG_E2E=$(KUBECONFIG_E2E) \
PRIVATE_KUBECONFIG_E2E=$(PRIVATE_KUBECONFIG_E2E) \
E2E_OPERATOR_URL=$(E2E_OPERATOR_URL) \
tools/helm-install-operator.sh

.PHONY: helm_lint
helm_lint: helm
helm lint helm/cloud-sql-operator

bin/install_to_helm: tools/install_to_helm.go
go build -o $@ $<

##
##@ Google Cloud End to End Test
Expand Down
25 changes: 25 additions & 0 deletions config/crd/bases/_.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2023 Google LLC
#
# 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: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
spec:
group: ""
names:
kind: ""
plural: ""
scope: ""
versions: null
23 changes: 23 additions & 0 deletions helm/cloud-sql-operator-crds/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
38 changes: 38 additions & 0 deletions helm/cloud-sql-operator-crds/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2023 Google LLC
#
# 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: v2
name: cloud-sql-operator-crds
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.2.0"

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions helm/cloud-sql-operator-crds/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 Google LLC
#
# 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.

operatorNamespace: "cloud-sql-proxy-operator-system"
operatorName: "cloud-sql-proxy-operator"
31 changes: 29 additions & 2 deletions helm/cloud-sql-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Copyright 2023 Google LLC
#
# 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: v2
name: cloud-sql-operator
description: A Helm chart for Kubernetes
description: A helm chart for the Cloud SQL Auth Proxy Operator

# A chart can be either an 'application' or a 'library' chart.
#
Expand All @@ -21,4 +35,17 @@ version: 0.1.0
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
appVersion: "1.2.0"

icon: https://lh3.googleusercontent.com/W3UEBKN5fp9DlpOe7N8rDi738TxH2BV61XKxmF3EFL15utdzE-rK99XBSnOjtXOKFyDf2-FnXnY=s48-w48-rw

## Add cert-manager chart as a dependency
#dependencies:
#- name: cloud-sql-operator-crds
# version: v1.13.1
# repository: ./charts/
# alias: cloud-sql-operator-crds
# version: v1.13.1
# repository: https://charts.jetstack.io
# alias: cert-manager
# condition: cert-manager.enabled
Binary file added helm/cloud-sql-operator/csql-icon.webp
Binary file not shown.
27 changes: 27 additions & 0 deletions helm/cloud-sql-operator/templates/Certificate-serving-cert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2023 Google LLC
#
# 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: cert-manager.io/v1
kind: Certificate
metadata:
name: {{ .Release.Name }}-serving-cert
namespace: {{ .Release.Namespace }}
spec:
dnsNames:
- {{ .Release.Name }}-webhook-service.{{ .Release.Namespace }}.svc
- {{ .Release.Name }}-webhook-service.{{ .Release.Namespace }}.svc.cluster.local
issuerRef:
kind: Issuer
name: {{ .Release.Name }}-selfsigned-issuer
secretName: webhook-server-cert
91 changes: 91 additions & 0 deletions helm/cloud-sql-operator/templates/ClusterRole-manager-role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Copyright 2023 Google LLC
#
# 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: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Release.Name }}-manager-role
rules:
- apiGroups:
- ""
resources:
- '*'
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- pods
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- '*'
verbs:
- get
- list
- watch
- apiGroups:
- apps
resources:
- daemonsets
- deployments
- replicasets
- statefulsets
verbs:
- patch
- update
- apiGroups:
- batch
resources:
- '*'
verbs:
- get
- list
- watch
- apiGroups:
- cloudsql.cloud.google.com
resources:
- authproxyworkloads
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- cloudsql.cloud.google.com
resources:
- authproxyworkloads/finalizers
verbs:
- update
- apiGroups:
- cloudsql.cloud.google.com
resources:
- authproxyworkloads/status
verbs:
- get
- patch
- update
23 changes: 23 additions & 0 deletions helm/cloud-sql-operator/templates/ClusterRole-metrics-reader.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2023 Google LLC
#
# 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: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Release.Name }}-metrics-reader
rules:
- nonResourceURLs:
- /metrics
verbs:
- get
31 changes: 31 additions & 0 deletions helm/cloud-sql-operator/templates/ClusterRole-proxy-role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2023 Google LLC
#
# 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: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Release.Name }}-proxy-role
rules:
- apiGroups:
- authentication.k8s.io
resources:
- tokenreviews
verbs:
- create
- apiGroups:
- authorization.k8s.io
resources:
- subjectaccessreviews
verbs:
- create
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2023 Google LLC
#
# 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: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ .Release.Name }}-manager-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ .Release.Name }}-manager-role
subjects:
- kind: ServiceAccount
name: {{ .Release.Name }}-controller-manager
namespace: {{ .Release.Namespace }}
Loading

0 comments on commit 0869192

Please sign in to comment.