Skip to content

wip: Helm Charts for the operator #483

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 39 additions & 6 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 Expand Up @@ -432,6 +457,7 @@ TERRAFORM ?= $(LOCALBIN)/terraform
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
GO_LICENSES ?= $(LOCALBIN)/go-licenses
CRD_REF_DOCS ?= $(LOCALBIN)/crd-ref-docs
HELM ?= $(LOCALBIN)/helm

## Tool Versions
# Important note: avoid adding spaces in the macro declarations as any
Expand All @@ -445,14 +471,15 @@ CRD_REF_DOCS_VERSION=v0.0.9# renovate datasource=go depName=github.com/elastic/c
ENVTEST_VERSION=v0.0.0-20230301194117-e2d8821b277f# renovate datasource=go depName=sigs.k8s.io/controller-runtime/tools/setup-envtest
GOLANGCI_LINT_VERSION=v1.51.2# renovate datasource=go depName=github.com/golangci/golangci-lint/cmd/golangci-lint
GO_LICENSES_VERSION=v1.6.0# renovate datasource=go depName=github.com/google/go-licenses
HELM_VERSION=v3.13.1# renovate datasource=go depName=github.com/helm/helm

KUSTOMIZE_VERSION=v4.5.2# don't manage with renovate, this repo has non-standard tags

GOOS?=$(shell go env GOOS | tr -d '\n')
GOARCH?=$(shell go env GOARCH | tr -d '\n')

remove_tools:
rm -rf $(KUSTOMIZE) $(CONTROLLER_GEN) $(KUBECTL) $(ENVTEST) $(TERRAFORM) $(GOLANGCI_LINT) $(CRD_REF_DOCS)
rm -rf $(KUSTOMIZE) $(CONTROLLER_GEN) $(KUBECTL) $(ENVTEST) $(TERRAFORM) $(GOLANGCI_LINT) $(CRD_REF_DOCS) $(HELM)

all_tools: kustomize controller-gen envtest kubectl terraform golangci-lint crd-ref-docs

Expand Down Expand Up @@ -516,8 +543,14 @@ gcloud:
exit 1)

.PHONY: helm
helm:
@which helm > /dev/null || \
(echo "Helm command line tools are not available in your path" ; \
echo "Instructions on how to install https://helm.sh/docs/helm/helm_install/ " ; \
exit 1)
helm: $(HELM)
$(HELM): $(LOCALBIN) ## Download helm locally if necessary.
test -s $@ || \
( curl -v -L -o [email protected] https://get.helm.sh/helm-$(HELM_VERSION)-$(GOOS)-$(GOARCH).tar.gz && \
cd $(LOCALBIN) && \
tar -zxf [email protected] && \
mv $(LOCALBIN)/$(GOOS)-$(GOARCH)/* $(LOCALBIN) && \
rm -rf $(LOCALBIN)/$(GOOS)-$(GOARCH) && \
rm -f [email protected] && \
chmod a+x $@ && \
touch $@ )
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
22 changes: 21 additions & 1 deletion docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,24 @@ Step 4: Run your e2e tests. The tests will read the contents of
the file `bin/last-local-proxy-url.txt`.

Delete the file `bin/last-local-proxy-url.txt` to go back to using
the public proxy iamge again
the public proxy iamge again

## Creating the helm chart

From the project root, the helm chart scaffolding was generated using
helm version 3.13.1.

```shell
# Download the latest helm tool
make helm

# Create the helm directory
mkdir -p helm
cd helm


# Create the operator helm chart
../bin/helm create cloud-sql-operator


```
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"
Loading