Skip to content

Commit

Permalink
chore: update node plugin image name and its refs (#131)
Browse files Browse the repository at this point in the history
* chore: update test/sanity/manifest.yaml
* fix: backwards-compatibility test
* fix: change csi driver name
* fix: compatible manifests to older CSI reference
* fix: restart-ds test
* bug-fix: missing testbase in restart-ds
* update: backwards compatibility test
* docs: add migration instructions in README
* chore: update version in Chart.yaml and Makefile

---------

Co-authored-by: Mriyam Tamuli <[email protected]>
  • Loading branch information
mugdha-adhav and mbtamuli authored Aug 15, 2024
1 parent 6b10664 commit 4c1e524
Show file tree
Hide file tree
Showing 51 changed files with 244 additions and 490 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/images-build-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
env:
BASE_REPOSITORY: warm-metal/container-image-csi-driver
BASE_DEFAULT_BRANCH: main
BASE_IMAGE_NAME: warmmetal/csi-image
BASE_IMAGE_NAME: warmmetal/container-image-csi-driver
FORK_IMAGE_NAME: ghcr.io/${{ github.repository }}

permissions:
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ RUN make build
RUN make install-util

FROM scratch as install-util
COPY --from=builder /go/src/container-image-csi-driver/_output/warm-metal-csi-image-install /
COPY --from=builder /go/src/container-image-csi-driver/_output/container-image-csi-driver-install /

FROM alpine:3.19
RUN apk add --no-cache btrfs-progs-dev lvm2-dev
WORKDIR /
COPY --from=builder /go/src/container-image-csi-driver/_output/csi-image-plugin /usr/bin/
ENTRYPOINT ["csi-image-plugin"]
COPY --from=builder /go/src/container-image-csi-driver/_output/container-image-csi-driver /usr/bin/
ENTRYPOINT ["container-image-csi-driver"]
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
VERSION ?= v1.2.4
VERSION ?= v2.0.0

IMAGE_BUILDER ?= docker
IMAGE_BUILD_CMD ?= buildx
REGISTRY ?= docker.io/warmmetal
PLATFORM ?= linux/amd64

export IMG = $(REGISTRY)/csi-image:$(VERSION)
export IMG = $(REGISTRY)/container-image-csi-driver:$(VERSION)

# cgo is required to build containers/storage
# For ubuntu, install libbtrfs-dev and libdevmapper-dev before building
.PHONY: build
build:
go fmt ./...
go vet ./...
go build -o _output/csi-image-plugin ./cmd/plugin
go build -o _output/container-image-csi-driver ./cmd/plugin

.PHONY: sanity
sanity:
Expand Down Expand Up @@ -45,11 +45,11 @@ integration:

.PHONY: image
image:
$(IMAGE_BUILDER) $(IMAGE_BUILD_CMD) build --platform=$(PLATFORM) -t $(REGISTRY)/csi-image:$(VERSION) --push .
$(IMAGE_BUILDER) $(IMAGE_BUILD_CMD) build --platform=$(PLATFORM) -t $(REGISTRY)/container-image-csi-driver:$(VERSION) --push .

.PHONY: local
local:
$(IMAGE_BUILDER) $(IMAGE_BUILD_CMD) build --platform=$(PLATFORM) -t $(REGISTRY)/csi-image:$(VERSION) --load .
$(IMAGE_BUILDER) $(IMAGE_BUILD_CMD) build --platform=$(PLATFORM) -t $(REGISTRY)/container-image-csi-driver:$(VERSION) --load .

.PHONY: test-deps
test-deps:
Expand All @@ -62,4 +62,4 @@ test-deps:
install-util:
GOOS=linux CGO_ENABLED="0" go build \
-ldflags "-X main.Version=$(VERSION) -X main.Registry=$(REGISTRY)" \
-o _output/warm-metal-csi-image-install ./cmd/install
-o _output/container-image-csi-driver-install ./cmd/install
40 changes: 26 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[![containerd](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/containerd.yaml/badge.svg)](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/containerd.yaml)
[![docker-containerd](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/docker-containerd.yaml/badge.svg)](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/docker-containerd.yaml)
[![cri-o](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/cri-o.yaml/badge.svg)](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/cri-o.yaml)
![Docker Pulls](https://img.shields.io/docker/pulls/warmmetal/csi-image?color=brightgreen&logo=docker&logoColor=lightgrey&labelColor=black)
![Docker Pulls](https://img.shields.io/docker/pulls/warmmetal/container-image-csi-driver?color=brightgreen&logo=docker&logoColor=lightgrey&labelColor=black)

# :construction_worker_man: :wrench: :construction: RENAMING THE REPOSITORY :construction: :wrench: :construction_worker_man:

Expand All @@ -28,6 +28,18 @@ git branch -u main main
git remote set-head origin -a
```

### Migration of CSI driver
In release `v2.0.0`, we are updating the CSI driver name from `csi-image.warm-metal.tech` to `container-image.warm-metal.tech`. This change may cause disruptions to your existing workloads if the driver name is not updated.

**To ensure a smooth transition:**
1. **Install Both Versions**: To avoid any breaking changes, you can install both the old and new versions of the CSI driver simultaneously. Both versions are compatible and have been tested to work side-by-side, as verified in our integration tests.

1. **Update Your Workloads**: Migrate your workloads to use the new driver name `container-image.warm-metal.tech`. This process will involve updating your storage class definitions and any other configurations that reference the old driver name.

1. **Remove the Old Driver**: Once all workloads have been successfully migrated and verified with the new driver, you can safely remove the older version of the driver from your cluster.

1. **Testing**: It is highly recommended to test the migration process in a staging environment before applying changes to production.

We appreciate your cooperation and understanding as we work to improve our repository.

# container-image-csi-driver (previously csi-driver-image)
Expand All @@ -48,7 +60,7 @@ then mounts images via the snapshot/storage service of the runtime.
## Compatibility matrix
Tested changes on below mentioned versions -

| warm-metal | k8s version | containerd | crio |
| CSI driver | k8s version | containerd | crio |
|------------|-------------|------------|---------|
| 0.6.x | v1.25 | 1.6.8 | v1.20.9 |
| 0.7.x | v1.25 | 1.6.8 | v1.20.9 |
Expand All @@ -62,26 +74,26 @@ Tested changes on below mentioned versions -
## Installation

The driver requires to mount various host paths for different container runtimes.
So, I build a binary utility, `warm-metal-csi-image-install`, to reduce the installation complexity.
So, I build a binary utility, `container-image-csi-driver-install`, to reduce the installation complexity.
It supports kubernetes, microk8s and k3s clusters with container runtime **cri-o**, **containerd** or **docker**.
Users can run this utility on any nodes in their clusters to generate proper manifests to install the driver.
The download link is available on the [release page](https://github.com/warm-metal/container-image-csi-driver/releases).

```shell script
# To print manifests
warm-metal-csi-image-install
container-image-csi-driver-install

# To show the detected configuration
warm-metal-csi-image-install --print-detected-instead
container-image-csi-driver-install --print-detected-instead

# To change the default namespace that the driver to be installed in
warm-metal-csi-image-install --namespace=foo
container-image-csi-driver-install --namespace=foo

# To set a Secret as the imagepullsecret
warm-metal-csi-image-install --pull-image-secret-for-daemonset=foo
container-image-csi-driver-install --pull-image-secret-for-daemonset=foo

# To disable the memroy cache for imagepullsecrets if Secrets are short-lived.
warm-metal-csi-image-install --pull-image-secret-for-daemonset=foo --enable-daemon-image-credential-cache=false
container-image-csi-driver-install --pull-image-secret-for-daemonset=foo --enable-daemon-image-credential-cache=false
```

You can found some installation manifests as samples in [examples](https://github.com/warm-metal/container-image-csi-driver/tree/master/sample).
Expand Down Expand Up @@ -126,7 +138,7 @@ spec:
volumes:
- name: target
csi:
driver: csi-image.warm-metal.tech
driver: container-image.csi.k8s.io
# nodePublishSecretRef:
# name: "ImagePullSecret name in the same namespace"
volumeAttributes:
Expand All @@ -145,14 +157,14 @@ kind: PersistentVolume
metadata:
name: pv-test-container-image-csi-driver-test-simple-fs
spec:
storageClassName: csi-image.warm-metal.tech
storageClassName: container-image.csi.k8s.io
capacity:
storage: 5Gi
accessModes:
- ReadOnlyMany
persistentVolumeReclaimPolicy: Retain
csi:
driver: csi-image.warm-metal.tech
driver: container-image.csi.k8s.io
volumeHandle: "docker.io/warmmetal/container-image-csi-driver-test:simple-fs"
# nodePublishSecretRef:
# name: "name of the ImagePullSecret"
Expand All @@ -178,12 +190,12 @@ Otherwise, you need ImagePullSecrets to store your credential. The following lin
- [https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#add-imagepullsecrets-to-a-service-account](https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#add-imagepullsecrets-to-a-service-account)

If the secret is desired to be shared by all volumes, you can add it to the ServiceAccount of the driver,
`csi-image-warm-metal` by default, and update the Role `csi-image-warm-metal` to make sure the daemon has permissions to fetch the secret,
then restart the driver daemon pod. Users can run `warm-metal-csi-image-install` to generate new manifests and apply them to update.
`container-image-csi-driver` by default, and update the Role `container-image-csi-driver` to make sure the daemon has permissions to fetch the secret,
then restart the driver daemon pod. Users can run `container-image-csi-driver-install` to generate new manifests and apply them to update.

```shell script
# use secrets foo and bar
warm-metal-csi-image-install --pull-image-secret-for-daemonset=foo --pull-image-secret-for-daemonset=bar
container-image-csi-driver-install --pull-image-secret-for-daemonset=foo --pull-image-secret-for-daemonset=bar
```

If the secret works only for particular workloads, you can set via the `nodePublishSecretRef` attribute of ephemeral volumes.
Expand Down
4 changes: 2 additions & 2 deletions charts/warm-metal-csi-driver/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ 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: 1.2.4
version: 2.0.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.
appVersion: v1.2.4
appVersion: v2.0.0
4 changes: 2 additions & 2 deletions charts/warm-metal-csi-driver/templates/csi-driver.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
name: csi-image.warm-metal.tech
name: container-image.csi.k8s.io
labels:
{{- include "warm-metal-csi-driver.labels" . | nindent 4 }}
spec:
Expand All @@ -12,4 +12,4 @@ spec:
- Ephemeral
{{- if (ge (int .Capabilities.KubeVersion.Minor) 20) }}
fsGroupPolicy: None
{{- end}}
{{- end}}
4 changes: 2 additions & 2 deletions charts/warm-metal-csi-driver/templates/nodeplugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
- name: node-driver-registrar
args:
- "--csi-address=/csi/csi.sock"
- --kubelet-registration-path={{ .Values.kubeletRoot }}/plugins/csi-image.warm-metal.tech/csi.sock
- --kubelet-registration-path={{ .Values.kubeletRoot }}/plugins/container-image.csi.k8s.io/csi.sock
- "-v={{ .Values.logLevel }}"
env:
- name: KUBE_NODE_NAME
Expand Down Expand Up @@ -119,7 +119,7 @@ spec:
serviceAccountName: {{ include "warm-metal-csi-driver.fullname" . }}-nodeplugin
volumes:
- hostPath:
path: {{ .Values.kubeletRoot }}/plugins/csi-image.warm-metal.tech
path: {{ .Values.kubeletRoot }}/plugins/container-image.csi.k8s.io
type: DirectoryOrCreate
name: socket-dir
- hostPath:
Expand Down
2 changes: 1 addition & 1 deletion charts/warm-metal-csi-driver/values-crio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ csiPlugin:
resources: {}
image:
tag: ""
repository: docker.io/warmmetal/csi-image
repository: docker.io/warmmetal/container-image-csi-driver
pullPolicy: IfNotPresent
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion charts/warm-metal-csi-driver/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ csiPlugin:
resources: {}
image:
tag: ""
repository: docker.io/warmmetal/csi-image
repository: docker.io/warmmetal/container-image-csi-driver
pullPolicy: IfNotPresent
livenessProbe:
httpGet:
Expand Down
30 changes: 15 additions & 15 deletions cmd/install/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func main() {
}

conf.EnableCache = *enableCache
conf.Image = fmt.Sprintf("%s/csi-image:%s", Registry, Version)
conf.Image = fmt.Sprintf("%s/container-image-csi-driver:%s", Registry, Version)

vols := detectImageSvcVolumes(conf.ImageSocketPath)
if len(vols) == 0 {
Expand Down Expand Up @@ -209,7 +209,7 @@ const staticManifests = `---
apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
name: csi-image.warm-metal.tech
name: container-image.csi.k8s.io
spec:
attachRequired: false
podInfoOnMount: true
Expand All @@ -223,7 +223,7 @@ const defaultSAManifests = `---
apiVersion: v1
kind: ServiceAccount
metadata:
name: csi-image-warm-metal
name: container-image-csi-driver
namespace: kube-system
---
`
Expand All @@ -232,13 +232,13 @@ const defaultRBACRoleManifests = `---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: csi-image-warm-metal
name: container-image-csi-driver
namespace: kube-system
rules:
- apiGroups:
- ""
resourceNames:
- csi-image-warm-metal
- container-image-csi-driver
resources:
- serviceaccounts
verbs:
Expand All @@ -250,15 +250,15 @@ const rbacRoleBindingManifests = `---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: csi-image-warm-metal
name: container-image-csi-driver
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: csi-image-warm-metal
name: container-image-csi-driver
subjects:
- kind: ServiceAccount
name: csi-image-warm-metal
name: container-image-csi-driver
namespace: kube-system
---
`
Expand All @@ -267,30 +267,30 @@ const dsTemplate = `---
kind: DaemonSet
apiVersion: apps/v1
metadata:
name: csi-image-warm-metal
name: container-image-csi-driver
namespace: kube-system
spec:
selector:
matchLabels:
app: csi-image-warm-metal
app: container-image-csi-driver
template:
metadata:
labels:
app: csi-image-warm-metal
app: container-image-csi-driver
spec:
hostNetwork: false
serviceAccountName: csi-image-warm-metal
serviceAccountName: container-image-csi-driver
containers:
- name: node-driver-registrar
image: quay.io/k8scsi/csi-node-driver-registrar:v1.1.0
imagePullPolicy: IfNotPresent
lifecycle:
preStop:
exec:
command: ["/bin/sh", "-c", "rm -rf /registration/csi-image.warm-metal.tech /registration/csi-image.warm-metal.tech-reg.sock"]
command: ["/bin/sh", "-c", "rm -rf /registration/container-image.csi.k8s.io /registration/container-image.csi.k8s.io-reg.sock"]
args:
- --csi-address=/csi/csi.sock
- --kubelet-registration-path={{.KubeletRoot}}/plugins/csi-image.warm-metal.tech/csi.sock
- --kubelet-registration-path={{.KubeletRoot}}/plugins/container-image.csi.k8s.io/csi.sock
env:
- name: KUBE_NODE_NAME
valueFrom:
Expand Down Expand Up @@ -332,7 +332,7 @@ spec:
name: runtime-socket
volumes:
- hostPath:
path: {{.KubeletRoot}}/plugins/csi-image.warm-metal.tech
path: {{.KubeletRoot}}/plugins/container-image.csi.k8s.io
type: DirectoryOrCreate
name: socket-dir
- hostPath:
Expand Down
4 changes: 2 additions & 2 deletions cmd/plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

const (
driverName = "csi-image.warm-metal.tech"
driverName = "container-image.csi.k8s.io"
driverVersion = "v1.0.0"

containerdScheme = "containerd"
Expand Down Expand Up @@ -55,7 +55,7 @@ var (
"If positive, specifies duration allotted for async image pulls as measured from pull start time. If zero, negative, less than 30s, or omitted, the caller's timeout (usually kubelet: 2m) is used instead of this value. (additional time helps prevent timeout for larger images or slower image pull conditions)")
watcherResyncPeriod = flag.Duration("watcher-resync-period", 30*time.Minute, "The resync period of the pvc watcher.")
mode = flag.String("mode", "", "The mode of the driver. Valid values are: node, controller")
nodePluginSA = flag.String("node-plugin-sa", "csi-image-warm-metal", "The name of the ServiceAccount used by the node plugin.")
nodePluginSA = flag.String("node-plugin-sa", "container-image-csi-driver", "The name of the ServiceAccount used by the node plugin.")
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion docs/automation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ There are a few [GitHub Workflows](https://docs.github.com/en/actions/using-work

## Build
- [![Create and publish the container image.](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/images-build-and-push.yaml/badge.svg)](https://github.com/warm-metal/container-image-csi-driver/actions/workflows/images-build-and-push.yaml)
- On the main repository - `warm-metal/container-image-csi-driver`, builds and pushes the container image to Docker Hub [`warmmetal/csi-image`](https://hub.docker.com/r/warmmetal/csi-image)
- On the main repository - `warm-metal/container-image-csi-driver`, builds and pushes the container image to Docker Hub [`warmmetal/container-image-csi-driver`](https://hub.docker.com/r/warmmetal/container-image-csi-driver)
- On any forks, builds and pushes the container image to `ghcr.io/<repository-name>`

## Tests
Expand Down
8 changes: 4 additions & 4 deletions hack/ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
set -e
set -x
VERSION=$(git rev-parse --short HEAD)
IMG=docker.io/warmmetal/csi-image:${VERSION}
IMG=docker.io/warmmetal/container-image-csi-driver:${VERSION}
BUILDER=$(docker buildx ls | grep ci-builderx || true)
[ "${BUILDER}" != "" ] || docker buildx create \
--name ci-builderx --driver docker-container \
--bootstrap \
--driver-opt image=moby/buildkit:master,network=host
docker buildx use ci-builderx
docker buildx build -t ${IMG} -o "type=oci,dest=csi-image.tar" .
kind load image-archive csi-image.tar -n kind-${GITHUB_RUN_ID}
docker buildx build -t ${IMG} -o "type=oci,dest=container-image-csi-driver.tar" .
kind load image-archive container-image-csi-driver.tar -n kind-${GITHUB_RUN_ID}
docker buildx build --target install-util -o "type=local,dest=_output/" .
set +e
set +e
Loading

0 comments on commit 4c1e524

Please sign in to comment.