From 600086624046aab2add0dcf7c95cd65f4767c807 Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Tue, 27 Aug 2024 17:23:08 +0200 Subject: [PATCH] cleanup --- hack/go-tools-build.sh | 87 ------------------- .../chart/cm-crd-sidecar.yaml | 30 ------- .../chart/kustomization.yaml | 22 ----- .../chart/patch-crd-sidecar.yaml | 46 ---------- .../chart/rbac-crd-aggregation.yaml | 24 ----- .../kube-state-metrics/chart/values.yaml | 22 ----- 6 files changed, 231 deletions(-) delete mode 100755 hack/go-tools-build.sh delete mode 100644 hack/observability/kube-state-metrics/chart/cm-crd-sidecar.yaml delete mode 100644 hack/observability/kube-state-metrics/chart/kustomization.yaml delete mode 100644 hack/observability/kube-state-metrics/chart/patch-crd-sidecar.yaml delete mode 100644 hack/observability/kube-state-metrics/chart/rbac-crd-aggregation.yaml delete mode 100644 hack/observability/kube-state-metrics/chart/values.yaml diff --git a/hack/go-tools-build.sh b/hack/go-tools-build.sh deleted file mode 100755 index db98d3da331a..000000000000 --- a/hack/go-tools-build.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2023 The Kubernetes Authors. -# -# 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. - -set -o errexit -set -o nounset -set -o pipefail - -if [ -z "${1}" ]; then - echo "must provide module as first parameter" - exit 1 -fi - -if [ -z "${2}" ]; then - echo "must provide binary name as second parameter" - exit 1 -fi - -if [ -z "${3}" ]; then - echo "must provide version as third parameter" - exit 1 -fi - -if [ -z "${GOBIN}" ]; then - echo "GOBIN is not set. Must set GOBIN to install the bin in a specified directory." - exit 1 -fi - -export GOWORK="off" - -GOMOD_REPLACE=${GOMOD_REPLACE:=} -GOMOD_REQUIRE=${GOMOD_REQUIRE:=} - -rm -f "${GOBIN}/${2}"* || true - -ORIGINAL_WORKDIR="$(pwd)" -TMP_MODULE_DIR="${2}.tmp" - -# Create TMP_MODULE_DIR to create a go module for building the binary. -# This is required because CAPI's hack/tools is not compatible to `go install`. -rm -r "${TMP_MODULE_DIR}" || true -mkdir -p "${TMP_MODULE_DIR}" -cd "${TMP_MODULE_DIR}" - -# Initialize a go module and place a tools.go file for building the binary. -go mod init "tools" - -for PARAM in ${GOMOD_REPLACE}; do - eval go mod edit -replace "${PARAM}" -done -for PARAM in ${GOMOD_REQUIRE}; do - eval go mod edit -require "${PARAM}" -done - -# Create go file which imports the required package and resolve dependencies. -cat << EOF > tools.go -//go:build tools -// +build tools -package tools - -import ( - _ "${1}" -) -EOF - -go mod tidy - -# Build the binary. -go build -tags=tools -o "${GOBIN}/${2}-${3}" "${1}" - -# Get back to the original directory and cleanup the temporary directory. -cd "${ORIGINAL_WORKDIR}" -rm -r "${TMP_MODULE_DIR}" - -# Link the unversioned name to the versioned binary. -ln -sf "${GOBIN}/${2}-${3}" "${GOBIN}/${2}" diff --git a/hack/observability/kube-state-metrics/chart/cm-crd-sidecar.yaml b/hack/observability/kube-state-metrics/chart/cm-crd-sidecar.yaml deleted file mode 100644 index 98c7eb16dfd3..000000000000 --- a/hack/observability/kube-state-metrics/chart/cm-crd-sidecar.yaml +++ /dev/null @@ -1,30 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: kube-state-metrics-crd-sidecar-script -data: - compile.sh: | - #!/bin/sh - - set -x - - SOURCE_DIR="/tmp" - TARGET_FILE="/etc/config/crd-config.yaml" - # This script will use a temporary file to only overwrite the target file once. - TARGET_FILE_TMP="${TARGET_FILE}.tmp" - - # Create header - cat << EOF > "${TARGET_FILE_TMP}" - kind: CustomResourceStateMetrics - spec: - resources: - EOF - - # Append custom resource config of all files but remove headers - for f in $(ls -1 ${SOURCE_DIR}/*.yaml); do - cat $f | grep -v -E -e '^(-|kind: CustomResourceStateMetrics|spec:| +resources:)' \ - >> "${TARGET_FILE_TMP}" - done - - # Overwrite target file - mv "${TARGET_FILE_TMP}" "${TARGET_FILE}" diff --git a/hack/observability/kube-state-metrics/chart/kustomization.yaml b/hack/observability/kube-state-metrics/chart/kustomization.yaml deleted file mode 100644 index 517ac6be0d3d..000000000000 --- a/hack/observability/kube-state-metrics/chart/kustomization.yaml +++ /dev/null @@ -1,22 +0,0 @@ -helmCharts: - - name: kube-state-metrics - repo: https://prometheus-community.github.io/helm-charts - namespace: observability - releaseName: kube-state-metrics - valuesFile: values.yaml - version: 5.8.1 - -helmGlobals: - # Store chart in ".charts" folder instead of "charts". - # Otherwise "go mod tidy" picks up dependencies of go files contained in the Helm Chart. - # "go mod tidy" ignores folders that begin with ".": https://pkg.go.dev/cmd/go#hdr-Package_lists_and_patterns. - chartHome: .charts - -resources: -- rbac-crd-aggregation.yaml -- cm-crd-sidecar.yaml - -patches: -- path: patch-crd-sidecar.yaml - target: - kind: Deployment \ No newline at end of file diff --git a/hack/observability/kube-state-metrics/chart/patch-crd-sidecar.yaml b/hack/observability/kube-state-metrics/chart/patch-crd-sidecar.yaml deleted file mode 100644 index d75d9db31ebe..000000000000 --- a/hack/observability/kube-state-metrics/chart/patch-crd-sidecar.yaml +++ /dev/null @@ -1,46 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: kube-state-metrics -spec: - template: - spec: - containers: - - env: - - name: LABEL - value: kube-state-metrics/custom-resource - - name: FOLDER - value: /tmp - - name: RESOURCE - value: configmap - - name: NAMESPACE - value: observability - - name: SCRIPT - value: /script/compile.sh - image: kiwigrid/k8s-sidecar:latest - name: crd-sidecar - volumeMounts: - - mountPath: /etc/config - name: config-volume - - mountPath: /script - name: compile-script - initContainers: - - command: - - /bin/sh - - -c - - | - cat << EOF > "/etc/config/crd-config.yaml" - kind: CustomResourceStateMetrics - spec: - resources: [] - EOF - image: kiwigrid/k8s-sidecar:latest - name: init-crd-config - volumeMounts: - - mountPath: /etc/config - name: config-volume - volumes: - - configMap: - defaultMode: 511 - name: kube-state-metrics-crd-sidecar-script - name: compile-script \ No newline at end of file diff --git a/hack/observability/kube-state-metrics/chart/rbac-crd-aggregation.yaml b/hack/observability/kube-state-metrics/chart/rbac-crd-aggregation.yaml deleted file mode 100644 index e6bd331ad60c..000000000000 --- a/hack/observability/kube-state-metrics/chart/rbac-crd-aggregation.yaml +++ /dev/null @@ -1,24 +0,0 @@ ---- -# ClusterRole to aggregate other ClusterRoles for different Custom Resource Configurations -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: kube-state-metrics-aggregated-role -aggregationRule: - clusterRoleSelectors: - - matchLabels: - kube-state-metrics/aggregate-to-manager: "true" ---- -# ClusterRoleBinding for the aggregation role -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: kube-state-metrics-custom-resource-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: kube-state-metrics-aggregated-role -subjects: -- kind: ServiceAccount - name: kube-state-metrics - namespace: observability \ No newline at end of file diff --git a/hack/observability/kube-state-metrics/chart/values.yaml b/hack/observability/kube-state-metrics/chart/values.yaml deleted file mode 100644 index faa58753e331..000000000000 --- a/hack/observability/kube-state-metrics/chart/values.yaml +++ /dev/null @@ -1,22 +0,0 @@ -# Add the CR configuration from the config map. -volumeMounts: - - mountPath: /etc/config - name: config-volume - -volumes: - - emptyDir: {} - name: config-volume - -extraArgs: -- "--custom-resource-state-config-file=/etc/config/crd-config.yaml" - -rbac: - extraRules: - - apiGroups: - - apiextensions.k8s.io - resources: - - customresourcedefinitions - verbs: - - get - - list - - watch