From baeaa6ee2b911153f51c11e5d86f739140a1326e Mon Sep 17 00:00:00 2001 From: Mark Yen Date: Wed, 13 Nov 2019 15:38:13 -0800 Subject: [PATCH 1/5] def.bzl: Bump cf-operator to v0.4.2-147.gb88e4296 This fixes issues with failing volume-management pods (though it has no actual impact, as far as we know). --- def.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/def.bzl b/def.bzl index d4b18116bf..b44b7397b6 100644 --- a/def.bzl +++ b/def.bzl @@ -6,8 +6,8 @@ project = struct( ), cf_operator = struct( chart = struct( - url = "https://cf-operators.s3.amazonaws.com/helm-charts/cf-operator-v0.4.2-146.ge5d49c17.tgz", - sha256 = "676e7e1c2dd589598c04f3960266daf7c11c62d3af9fbf621aeb06707b25e1bf", + url = "https://s3.amazonaws.com/cf-operators/helm-charts/cf-operator-v0.4.2-147.gb88e4296.tgz", + sha256 = "7cc0c23df3aa5fb7f2075e3dbd77d2dc51c1ee283060ae9cb46ed680b1deb1d0", ), namespace = "cfo", ), From 0e233688016958c5241f5b12d15fa7cda5ee8254 Mon Sep 17 00:00:00 2001 From: Mark Yen Date: Fri, 15 Nov 2019 13:41:42 -0800 Subject: [PATCH 2/5] ingress: fix ingress template Removing the whitespace at the end of the conditional ended up with the next line stuck to the previous line, producing invalid YAML. --- deploy/helm/kubecf/templates/ingress.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/helm/kubecf/templates/ingress.yaml b/deploy/helm/kubecf/templates/ingress.yaml index 629bcb6f7a..abd24e2ffa 100644 --- a/deploy/helm/kubecf/templates/ingress.yaml +++ b/deploy/helm/kubecf/templates/ingress.yaml @@ -22,7 +22,7 @@ metadata: data: tls.crt: {{ .Values.features.ingress.tls.crt | b64enc | quote }} tls.key: {{ .Values.features.ingress.tls.key | b64enc | quote }} -{{- end -}} +{{- end }} --- # This ingress specifies routing and access for the cloud controller public Kubecf service, e.g. # "api." and other services in that domain hierarchy. From 0c9eb07c71e537cbf6b170db22303c6a5bfad55a Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Wed, 13 Nov 2019 16:25:13 +0100 Subject: [PATCH 3/5] Annotate operator chart url in Chart.yaml Add macro to generate chart metadata that creates a new file, Metadata.yaml containing custom key/values used for kubecf Closes #124 --- deploy/helm/kubecf/BUILD.bazel | 16 +++++++++++++++- deploy/helm/kubecf/defs.bzl | 8 ++++++++ rules/helm/def.bzl | 5 ++++- rules/helm/package.sh | 9 ++++++++- 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 deploy/helm/kubecf/defs.bzl diff --git a/deploy/helm/kubecf/BUILD.bazel b/deploy/helm/kubecf/BUILD.bazel index 2c3c7f9893..ec3b3198c9 100644 --- a/deploy/helm/kubecf/BUILD.bazel +++ b/deploy/helm/kubecf/BUILD.bazel @@ -2,12 +2,23 @@ package(default_visibility = ["//visibility:public"]) load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar") load("//rules/helm:def.bzl", helm_package = "package") +load("//:def.bzl", "project") +load("//deploy/helm/kubecf:defs.bzl", "metadata_file_generator") + +metadata_file_generator( + name = "metadata", + file = "Metadata.yaml", + operator_chart = project.cf_operator.chart.url +) filegroup( name = "chart_files_static", srcs = glob( ["**/*"], - exclude = ["**/BUILD.bazel"], + exclude = [ + "**/BUILD.bazel", + "**/defs.bzl", + ], ), ) @@ -24,6 +35,9 @@ helm_package( srcs = [ ":chart_files_static", ], + generated = [ + ":metadata", + ], tars = [ ":cf_deployment", "//bosh/releases:pre_render_scripts", diff --git a/deploy/helm/kubecf/defs.bzl b/deploy/helm/kubecf/defs.bzl new file mode 100644 index 0000000000..fa7111b79c --- /dev/null +++ b/deploy/helm/kubecf/defs.bzl @@ -0,0 +1,8 @@ +def metadata_file_generator(name, file, operator_chart, visibility=None): + native.genrule( + name = name, + srcs = [], + outs = [file], + cmd = "echo 'operatorChartUrl: \"{}\"' > $@".format(operator_chart), + visibility = visibility, + ) diff --git a/rules/helm/def.bzl b/rules/helm/def.bzl index 863cd025fa..14884d5039 100644 --- a/rules/helm/def.bzl +++ b/rules/helm/def.bzl @@ -3,7 +3,7 @@ def _package_impl(ctx): output_tgz = ctx.actions.declare_file(output_filename) outputs = [output_tgz] ctx.actions.run( - inputs = [] + ctx.files.srcs + ctx.files.tars, + inputs = [] + ctx.files.srcs + ctx.files.tars + ctx.files.generated, outputs = outputs, tools = [ctx.executable._helm], progress_message = "Generating Helm package archive {}".format(output_filename), @@ -12,6 +12,8 @@ def _package_impl(ctx): "PACKAGE_DIR": ctx.attr.package_dir, # TODO(f0rmiga): Figure out a way of working with paths that contain spaces. "TARS": " ".join([f.path for f in ctx.files.tars]), + # TODO(mudler): Support also nested folders and paths with spaces + "GENERATED": " ".join([f.path for f in ctx.files.generated]), "HELM": ctx.executable._helm.path, "CHART_VERSION": ctx.attr.chart_version, "APP_VERSION": ctx.attr.app_version, @@ -27,6 +29,7 @@ _package = rule( "srcs": attr.label_list( mandatory = True, ), + "generated": attr.label_list(), "tars": attr.label_list(), "package_dir": attr.string( mandatory = True, diff --git a/rules/helm/package.sh b/rules/helm/package.sh index 30e3cf609b..b7b63a4a2b 100755 --- a/rules/helm/package.sh +++ b/rules/helm/package.sh @@ -4,10 +4,17 @@ set -o errexit -o nounset build_dir="tmp/build/${PACKAGE_DIR}" mkdir -p "${build_dir}" + cp -L -R "${PACKAGE_DIR}"/* "${build_dir}" +# Generated files ( here TARS, GENERATED ) are not part of the source code +# to be able to use them, we have to copy them for t in ${TARS}; do - tar xf "${t}" -C "${build_dir}" + tar xf "${t}" -C "${build_dir}" > /dev/null +done + +for g in ${GENERATED}; do + cp "${g}" "${build_dir}"/ > /dev/null done "${HELM}" init --client-only > /dev/null From 4d7e3433887e6758595eaa78a6a6789bab0ccec7 Mon Sep 17 00:00:00 2001 From: Dimitris Karakasilis Date: Thu, 14 Nov 2019 12:19:42 +0200 Subject: [PATCH 4/5] Let the user configure the storage class used for components --- .../kubecf/assets/operations/instance_groups/bits.yaml | 9 +++++---- .../assets/operations/instance_groups/database.yaml | 7 +++++-- .../operations/instance_groups/singleton-blobstore.yaml | 8 +++++--- deploy/helm/kubecf/values.yaml | 5 +++++ 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/deploy/helm/kubecf/assets/operations/instance_groups/bits.yaml b/deploy/helm/kubecf/assets/operations/instance_groups/bits.yaml index 65094979a4..50878b376b 100644 --- a/deploy/helm/kubecf/assets/operations/instance_groups/bits.yaml +++ b/deploy/helm/kubecf/assets/operations/instance_groups/bits.yaml @@ -50,13 +50,14 @@ value: local # Attach a persistent disk to bits-service VM to store eirinifs -# TODO: storage class type should be configurable -# - type: replace -# path: /instance_groups/name=bits/persistent_disk_type? -# value: ??? - type: replace path: /instance_groups/name=bits/persistent_disk? value: 20480 # 20GB +{{- if .Values.kube.storage_class }} +- type: replace + path: /instance_groups/name=bits/persistent_disk_type? + value: {{ .Values.kube.storage_class }} +{{- end }} - type: replace path: /instance_groups/name=api/jobs/name=cloud_controller_ng/properties/cc/bits_service?/enabled? diff --git a/deploy/helm/kubecf/assets/operations/instance_groups/database.yaml b/deploy/helm/kubecf/assets/operations/instance_groups/database.yaml index 4fc815aeec..083deb398d 100644 --- a/deploy/helm/kubecf/assets/operations/instance_groups/database.yaml +++ b/deploy/helm/kubecf/assets/operations/instance_groups/database.yaml @@ -16,11 +16,14 @@ sha1: ~ # Configure the persistent disk in the way that cf-operator can provision. -- type: remove - path: /instance_groups/name=database/persistent_disk_type - type: replace path: /instance_groups/name=database/persistent_disk? value: 20480 # 20GB +{{- if .Values.kube.storage_class }} +- type: replace + path: /instance_groups/name=database/persistent_disk_type + value: {{ .Values.kube.storage_class }} +{{- end }} # Replace the jobs using the cf-mysql-release. - type: replace diff --git a/deploy/helm/kubecf/assets/operations/instance_groups/singleton-blobstore.yaml b/deploy/helm/kubecf/assets/operations/instance_groups/singleton-blobstore.yaml index dfea80d470..57ccf3db20 100644 --- a/deploy/helm/kubecf/assets/operations/instance_groups/singleton-blobstore.yaml +++ b/deploy/helm/kubecf/assets/operations/instance_groups/singleton-blobstore.yaml @@ -1,9 +1,11 @@ -# Configure the persistent disk in the way that cf-operator can provision. -- type: remove - path: /instance_groups/name=singleton-blobstore/persistent_disk_type - type: replace path: /instance_groups/name=singleton-blobstore/persistent_disk? value: 102400 # 100GB +{{- if .Values.kube.storage_class }} +- type: replace + path: /instance_groups/name=singleton-blobstore/persistent_disk_type + value: {{ .Values.kube.storage_class }} +{{- end }} - type: replace path: /instance_groups/name=singleton-blobstore/jobs/name=blobstore/properties/blobstore/internal_access_rules? diff --git a/deploy/helm/kubecf/values.yaml b/deploy/helm/kubecf/values.yaml index abda4aa596..15cc421514 100644 --- a/deploy/helm/kubecf/values.yaml +++ b/deploy/helm/kubecf/values.yaml @@ -12,6 +12,11 @@ deployment_name: kubecf # addr: kubecf-log-api:8082 properties: {} +# The the storage class to be used for the instance groups that need it (e.g. bits, database and singleton-blobstore) +# If it's not set, the default storage class will be used. +kube: + storage_class: ~ + releases: # The defaults for all releases, where we do not otherwise override them. defaults: From 2254ddcf961d634d46df0dff81785dba07dc8a31 Mon Sep 17 00:00:00 2001 From: Thulio Ferraz Assis Date: Mon, 18 Nov 2019 15:46:12 -0800 Subject: [PATCH 5/5] Fixed storage class when none is provided --- .../kubecf/assets/operations/instance_groups/database.yaml | 3 +++ .../assets/operations/instance_groups/singleton-blobstore.yaml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/deploy/helm/kubecf/assets/operations/instance_groups/database.yaml b/deploy/helm/kubecf/assets/operations/instance_groups/database.yaml index 083deb398d..92d43355fe 100644 --- a/deploy/helm/kubecf/assets/operations/instance_groups/database.yaml +++ b/deploy/helm/kubecf/assets/operations/instance_groups/database.yaml @@ -23,6 +23,9 @@ - type: replace path: /instance_groups/name=database/persistent_disk_type value: {{ .Values.kube.storage_class }} +{{- else }} +- type: remove + path: /instance_groups/name=database/persistent_disk_type {{- end }} # Replace the jobs using the cf-mysql-release. diff --git a/deploy/helm/kubecf/assets/operations/instance_groups/singleton-blobstore.yaml b/deploy/helm/kubecf/assets/operations/instance_groups/singleton-blobstore.yaml index 57ccf3db20..1210827e49 100644 --- a/deploy/helm/kubecf/assets/operations/instance_groups/singleton-blobstore.yaml +++ b/deploy/helm/kubecf/assets/operations/instance_groups/singleton-blobstore.yaml @@ -5,6 +5,9 @@ - type: replace path: /instance_groups/name=singleton-blobstore/persistent_disk_type value: {{ .Values.kube.storage_class }} +{{- else }} +- type: remove + path: /instance_groups/name=singleton-blobstore/persistent_disk_type {{- end }} - type: replace