Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Multus update #2

Merged
merged 3 commits into from
Sep 11, 2024
Merged
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
48 changes: 48 additions & 0 deletions .github/workflows/helm_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Helm Charts Test

on:
push:
branches:
- main
- 'release/**'
pull_request:
branches:
- main
- 'release/**'
workflow_dispatch: # Allows manually triggering the workflow

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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.idea
/scratch
4 changes: 2 additions & 2 deletions multus/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions multus/templates/clusterRole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ rules:
- events
verbs:
- create
- patch
- update
{{- end }}
{{- end }}
45 changes: 45 additions & 0 deletions multus/templates/crds/net-def.yaml
Original file line number Diff line number Diff line change
@@ -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
43 changes: 0 additions & 43 deletions multus/templates/customResourceDefinition.yaml

This file was deleted.

40 changes: 25 additions & 15 deletions multus/templates/daemonSet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,19 @@ 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:
- name: KUBERNETES_NODE_NAME
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 }}
Expand All @@ -73,22 +70,35 @@ 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:
path: /etc/cni/net.d
- 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 }}
2 changes: 1 addition & 1 deletion multus/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

image:
repository: ghcr.io/k8snetworkplumbingwg/multus-cni
tag: v3.8
tag: v4.1.0
pullPolicy: IfNotPresent

#imagePullSecrets: []
Expand Down
22 changes: 22 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -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 <chart_directory> <release_name> <manifest_url>
39 changes: 39 additions & 0 deletions scripts/compare_chart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Usage: ./compare_chart.sh <chart_directory> <release_name> <manifest_url>

# Check if correct number of arguments is provided
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <chart_directory> <release_name> <manifest_url>"
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