From ad787bd9fcf8847890f73305c94fa3cd33bc03c6 Mon Sep 17 00:00:00 2001 From: jdambly Date: Tue, 10 Sep 2024 20:04:30 -0700 Subject: [PATCH 1/3] intial commit for multus upgrade --- .gitignore | 2 + multus/Chart.yaml | 4 +- multus/templates/clusterRole.yaml | 2 + multus/templates/crds/net-def.yaml | 45 +++++++++++++++++++ .../templates/customResourceDefinition.yaml | 43 ------------------ multus/templates/daemonSet.yaml | 40 ++++++++++------- multus/values.yaml | 2 +- scripts/README.md | 22 +++++++++ scripts/compare_chart.sh | 39 ++++++++++++++++ 9 files changed, 138 insertions(+), 61 deletions(-) create mode 100644 .gitignore create mode 100644 multus/templates/crds/net-def.yaml delete mode 100644 multus/templates/customResourceDefinition.yaml create mode 100644 scripts/README.md create mode 100755 scripts/compare_chart.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b28d17b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/.idea +/scratch diff --git a/multus/Chart.yaml b/multus/Chart.yaml index 5c4a0d8..67355b6 100644 --- a/multus/Chart.yaml +++ b/multus/Chart.yaml @@ -15,11 +15,11 @@ apiVersion: v2 name: multus description: Multus Helm chart for Kubernetes type: application -version: 0.1.2 +version: 0.1.3 home: https://github.com/intel/multus-cni icon: https://raw.githubusercontent.com/intel/multus-cni/master/doc/images/Multus.png sources: - https://github.com/intel/multus-cni maintainers: - name: Network Plumbing Group -appVersion: 0.1.0 +appVersion: 2.8.0 diff --git a/multus/templates/clusterRole.yaml b/multus/templates/clusterRole.yaml index 6546262..9615bff 100644 --- a/multus/templates/clusterRole.yaml +++ b/multus/templates/clusterRole.yaml @@ -37,5 +37,7 @@ rules: - events verbs: - create + - patch + - update {{- end }} {{- end }} diff --git a/multus/templates/crds/net-def.yaml b/multus/templates/crds/net-def.yaml new file mode 100644 index 0000000..24b2c58 --- /dev/null +++ b/multus/templates/crds/net-def.yaml @@ -0,0 +1,45 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: network-attachment-definitions.k8s.cni.cncf.io +spec: + group: k8s.cni.cncf.io + scope: Namespaced + names: + plural: network-attachment-definitions + singular: network-attachment-definition + kind: NetworkAttachmentDefinition + shortNames: + - net-attach-def + versions: + - name: v1 + served: true + storage: true + schema: + openAPIV3Schema: + description: 'NetworkAttachmentDefinition is a CRD schema specified by the Network Plumbing + Working Group to express the intent for attaching pods to one or more logical or physical + networks. More information available at: https://github.com/k8snetworkplumbingwg/multi-net-spec' + type: object + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this represen + tation of an object. Servers should convert recognized schemas to the + latest internal value, and may reject unrecognized values. More info: + https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: 'NetworkAttachmentDefinition spec defines the desired state of a network attachment' + type: object + properties: + config: + description: 'NetworkAttachmentDefinition config is a JSON-formatted CNI configuration' + type: string diff --git a/multus/templates/customResourceDefinition.yaml b/multus/templates/customResourceDefinition.yaml deleted file mode 100644 index d86bf91..0000000 --- a/multus/templates/customResourceDefinition.yaml +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright 2020 K8s Network Plumbing Group -# -# 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. -{{- if or ( gt .Capabilities.KubeVersion.Major "1" ) ( ge .Capabilities.KubeVersion.Minor "16" ) }} -{{- if .Values.manifests.customResourceDefinition }} -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: network-attachment-definitions.k8s.cni.cncf.io -spec: - group: k8s.cni.cncf.io - scope: Namespaced - names: - plural: network-attachment-definitions - singular: network-attachment-definition - kind: NetworkAttachmentDefinition - shortNames: - - net-attach-def - versions: - - name: v1 - served: true - storage: true - schema: - openAPIV3Schema: - type: object - properties: - spec: - type: object - properties: - config: - type: string -{{- end }} -{{- end }} diff --git a/multus/templates/daemonSet.yaml b/multus/templates/daemonSet.yaml index de7ad73..5d882a7 100644 --- a/multus/templates/daemonSet.yaml +++ b/multus/templates/daemonSet.yaml @@ -47,7 +47,7 @@ spec: effect: NoSchedule serviceAccountName: {{ .Values.serviceAccount.name }} containers: - - name: kube-{{ .Chart.Name }} + - name: multus image: {{ .Values.image.repository }}:{{ .Values.image.tag }} imagePullPolicy: {{ .Values.image.pullPolicy }} env: @@ -55,14 +55,11 @@ spec: valueFrom: fieldRef: fieldPath: spec.nodeName - command: - - /bin/bash - - -cex - - | - #!/bin/bash - sed "s|__KUBERNETES_NODE_NAME__|${KUBERNETES_NODE_NAME}|g" /tmp/multus-conf/00-multus.conf.template > /tmp/multus-conf/00-multus.conf - /entrypoint.sh \ - --multus-conf-file=/tmp/multus-conf/00-multus.conf + command: ["/thin_entrypoint"] + args: + - "--multus-conf-file=auto" + - "--multus-autoconfig-dir=/host/etc/cni/net.d" + - "--cni-conf-dir=/host/etc/cni/net.d" {{- if .Values.pod.resources.multus }} resources: {{- toYaml .Values.pod.resources.multus | nindent 10 }} {{- end }} @@ -73,11 +70,26 @@ spec: mountPath: /host/etc/cni/net.d - name: cnibin mountPath: /host/opt/cni/bin - {{- if .Values.manifests.configMap }} - name: multus-cfg - mountPath: /tmp/multus-conf/00-multus.conf.template - subPath: "cni-conf.json" - {{- end }} + mountPath: /tmp/multus-conf + initContainers: + - name: install-multus-binary + image: {{ .Values.image.repository }}:{{ .Values.image.tag }} + command: [ "/install_multus" ] + args: + - "--type" + - "thin" + resources: + requests: + cpu: "10m" + memory: "15Mi" + securityContext: + privileged: true + terminationMessagePolicy: FallbackToLogsOnError + volumeMounts: + - name: cnibin + mountPath: /host/opt/cni/bin + mountPropagation: Bidirectional volumes: - name: cni hostPath: @@ -85,10 +97,8 @@ spec: - name: cnibin hostPath: path: /opt/cni/bin - {{- if .Values.manifests.configMap }} - name: multus-cfg configMap: name: {{ .Release.Name }}-{{ .Chart.Name }}-{{ .Chart.Version }}-config - {{- end }} {{- end }} {{- end }} diff --git a/multus/values.yaml b/multus/values.yaml index b940bec..c5fa920 100644 --- a/multus/values.yaml +++ b/multus/values.yaml @@ -20,7 +20,7 @@ image: repository: ghcr.io/k8snetworkplumbingwg/multus-cni - tag: v3.8 + tag: v4.1.0 pullPolicy: IfNotPresent #imagePullSecrets: [] diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..0145a4e --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,22 @@ +# Helm Chart Comparison Script + +This script allows you to compare a rendered Helm chart with the latest manifest from a specified GitHub repository. It is particularly useful for keeping your Kubernetes deployments up to date by ensuring that your Helm charts match the latest official manifests. + +## Features + +- **Generic Usage**: Easily adaptable to any Helm chart and GitHub manifest. +- **Scratch Directory**: Uses a `scratch` directory for temporary files, which is ignored by Git. +- **Simple Comparison**: Provides a unified diff between your Helm chart and the latest manifest. + +## Prerequisites + +- **Helm**: Ensure Helm is installed and configured. +- **curl**: Used to download the latest manifest from the GitHub repository. +- **diff**: Standard tool for comparing files. + +## Usage + +### Script Syntax + +```bash +./compare_chart.sh diff --git a/scripts/compare_chart.sh b/scripts/compare_chart.sh new file mode 100755 index 0000000..5bff765 --- /dev/null +++ b/scripts/compare_chart.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# Usage: ./compare_chart.sh + +# Check if correct number of arguments is provided +if [ "$#" -ne 3 ]; then + echo "Usage: $0 " + exit 1 +fi + +CHART_DIR=$1 +RELEASE_NAME=$2 +MANIFEST_URL=$3 + +# Define scratch directory and output file names +SCRATCH_DIR="./scratch" +mkdir -p ${SCRATCH_DIR} + +CURRENT_YAML="${SCRATCH_DIR}/current-${RELEASE_NAME}.yaml" +LATEST_YAML="${SCRATCH_DIR}/latest-${RELEASE_NAME}.yaml" + +# Fetch the latest manifest +curl -o ${LATEST_YAML} ${MANIFEST_URL} +if [ $? -ne 0 ]; then + echo "Failed to download the manifest from ${MANIFEST_URL}" + exit 1 +fi + +# Render the Helm chart +helm template ${RELEASE_NAME} ${CHART_DIR} > ${CURRENT_YAML} +if [ $? -ne 0 ]; then + echo "Failed to render Helm chart from ${CHART_DIR}" + exit 1 +fi + +# Compare the files side by side +diff -y ${CURRENT_YAML} ${LATEST_YAML} + +# The files will remain in the scratch directory for review From fcd765a0f5fcfd26811bfa3c4d5874208a79cfd7 Mon Sep 17 00:00:00 2001 From: jdambly Date: Tue, 10 Sep 2024 20:04:30 -0700 Subject: [PATCH 2/3] intial commit for multus upgrade --- .github/workflows/helm_test.yml | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/helm_test.yml diff --git a/.github/workflows/helm_test.yml b/.github/workflows/helm_test.yml new file mode 100644 index 0000000..c54eab6 --- /dev/null +++ b/.github/workflows/helm_test.yml @@ -0,0 +1,47 @@ +name: Helm Charts Test + +on: + push: + branches: + - main + - 'release/**' + pull_request: + branches: + - main + - 'release/**' + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + chart: [multus,sriov, whereabouts] # Add all your chart directories here + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Helm + uses: azure/setup-helm@v3 + with: + version: 'v3.12.0' # specify the Helm version you want to use + + - name: Set up Kubernetes (kind) + uses: helm/kind-action@v1.2.0 + with: + version: v0.17.0 # specify the kind version you want to use + + - name: Helm Lint + run: helm lint ${{ matrix.chart }} + + - name: Install dependencies + run: helm dependency update ${{ matrix.chart }} + + - name: Install Helm chart + run: helm install --wait --timeout 60s --dry-run ${{ matrix.chart }}-release ${{ matrix.chart }} + + - name: Run Helm tests + run: helm test ${{ matrix.chart }}-release --timeout 60s + + - name: Delete Helm release + run: helm uninstall ${{ matrix.chart }}-release From 6ae6f2ac5c3141b08f9e58cb5f6e4662dd02effe Mon Sep 17 00:00:00 2001 From: jdambly Date: Wed, 11 Sep 2024 10:10:02 -0700 Subject: [PATCH 3/3] Allows manually triggering the workflow --- .github/workflows/helm_test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/helm_test.yml b/.github/workflows/helm_test.yml index c54eab6..1144c83 100644 --- a/.github/workflows/helm_test.yml +++ b/.github/workflows/helm_test.yml @@ -9,6 +9,7 @@ on: branches: - main - 'release/**' + workflow_dispatch: # Allows manually triggering the workflow jobs: test: