Skip to content

Commit 52e0931

Browse files
shyamradhakrishnanmrunalpagnis
authored andcommitted
Add arm image support and minor bug fix
1 parent 1670f88 commit 52e0931

File tree

7 files changed

+75
-17
lines changed

7 files changed

+75
-17
lines changed

Dockerfile_arm_all

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
ARG CI_IMAGE_REGISTRY
2+
3+
FROM ${CI_IMAGE_REGISTRY}/oci-kube-ci:1.0.5 as builder
4+
5+
ARG COMPONENT
6+
7+
ENV SRC /go/src/github.com/oracle/oci-cloud-controller-manager
8+
9+
ENV GOPATH /go/
10+
RUN mkdir -p /go/bin $SRC
11+
ADD . $SRC
12+
13+
WORKDIR $SRC
14+
15+
RUN ARCH=arm make clean build-arm-all
16+
17+
FROM arm64v8/oraclelinux:7-slim
18+
19+
RUN yum install -y util-linux \
20+
&& yum install -y e2fsprogs \
21+
&& yum clean all
22+
\
23+
24+
COPY --from=0 /go/src/github.com/oracle/oci-cloud-controller-manager/dist/arm/* /usr/local/bin/

Makefile

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
1615
PKG := github.com/oracle/oci-cloud-controller-manager
1716

1817
ifeq "$(CI_IMAGE_REGISTRY)" ""
@@ -29,6 +28,8 @@ endif
2928
IMAGE ?= $(OSS_REGISTRY)/cloud-provider-oci
3029
COMPONENT ?= oci-cloud-controller-manager oci-volume-provisioner oci-flexvolume-driver oci-csi-controller-driver oci-csi-node-driver
3130

31+
ALL_ARCH = amd64 arm64
32+
3233
ifeq "$(VERSION)" ""
3334
BUILD := $(shell git describe --exact-match 2> /dev/null || git describe --match=$(git rev-parse --short=8 HEAD) --always --dirty --abbrev=8)
3435
# Allow overriding for release versions else just equal the build (git hash)
@@ -139,13 +140,39 @@ run-volume-provisioner-dev:
139140
BUILD_ARGS = --build-arg CI_IMAGE_REGISTRY="$(CI_IMAGE_REGISTRY)" --build-arg COMPONENT="$(COMPONENT)"
140141
image:
141142
docker build $(BUILD_ARGS) \
142-
-t $(IMAGE):$(VERSION) .
143+
-t $(IMAGE)-amd64:$(VERSION) .
144+
docker build $(BUILD_ARGS) \
145+
-t $(IMAGE)-arm64:$(VERSION) -f Dockerfile_arm_all .
143146

144147
.PHONY: push
145148
push: image
146149
docker login --username="${oss_docker_username}" --password="${oss_docker_password}" $(OSS_REGISTRY)
147150
docker push $(IMAGE):$(VERSION)
148151

152+
.PHONY: build
153+
build-arm-all: build-dirs
154+
@for component in $(COMPONENT); do \
155+
GOOS=$(GOOS) GOARCH=arm64 CGO_ENABLED=0 go build -o dist/arm/$$component -ldflags "-X main.version=$(VERSION) -X main.build=$(BUILD)" ./cmd/$$component ; \
156+
done
157+
158+
.PHONY: docker-push
159+
docker-push: ## Push the docker image
160+
docker push $(IMAGE)-$(ARCH):$(VERSION)
161+
162+
docker-push-%:
163+
$(MAKE) ARCH=$* docker-push
164+
165+
.PHONY: docker-push-all ## Push all the architecture docker images
166+
docker-push-all: $(addprefix docker-push-,$(ALL_ARCH))
167+
$(MAKE) docker-push-manifest
168+
169+
.PHONY: docker-push-manifest
170+
docker-push-manifest: ## Push the fat manifest docker image.
171+
## Minimum docker version 18.06.0 is required for creating and pushing manifest images.
172+
docker manifest create --amend $(IMAGE):$(VERSION) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(IMAGE)\-&:$(VERSION)~g")
173+
@for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${IMAGE}:${VERSION} ${IMAGE}-$${arch}:${VERSION}; done
174+
docker manifest push --purge ${IMAGE}:${VERSION}
175+
149176
.PHONY: version
150177
version:
151178
@echo $(VERSION)

manifests/cloud-controller-manager/oci-cloud-controller-manager-rbac.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
name: cloud-controller-manager
66
namespace: kube-system
77
---
8-
apiVersion: rbac.authorization.k8s.io/v1beta1
8+
apiVersion: rbac.authorization.k8s.io/v1
99
kind: ClusterRole
1010
metadata:
1111
name: system:cloud-controller-manager
@@ -137,7 +137,7 @@ rules:
137137
- patch
138138
---
139139
kind: ClusterRoleBinding
140-
apiVersion: rbac.authorization.k8s.io/v1beta1
140+
apiVersion: rbac.authorization.k8s.io/v1
141141
metadata:
142142
name: oci-cloud-controller-manager
143143
roleRef:

manifests/container-storage-interface/oci-csi-controller-driver.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ spec:
2222
node-role.kubernetes.io/master: ""
2323
containers:
2424
- name: csi-volume-provisioner
25-
image: quay.io/k8scsi/csi-provisioner:v1.6.0
25+
image: k8s.gcr.io/sig-storage/csi-provisioner:v2.2.2
2626
args:
2727
- --csi-address=/var/run/shared-tmpfs/csi.sock
2828
- --volume-name-prefix=csi
2929
- --feature-gates=Topology=true
3030
- --timeout=120s
31-
- --enable-leader-election=true
32-
- --leader-election-type=leases
31+
- --leader-election
3332
- --leader-election-namespace=kube-system
3433
volumeMounts:
3534
- name: config
@@ -38,7 +37,7 @@ spec:
3837
- mountPath: /var/run/shared-tmpfs
3938
name: shared-tmpfs
4039
- name: csi-attacher
41-
image: quay.io/k8scsi/csi-attacher:v2.2.0
40+
image: k8s.gcr.io/sig-storage/csi-attacher:v3.4.0
4241
args:
4342
- --csi-address=/var/run/shared-tmpfs/csi.sock
4443
- --timeout=120s
@@ -51,9 +50,8 @@ spec:
5150
- mountPath: /var/run/shared-tmpfs
5251
name: shared-tmpfs
5352
- name: csi-resizer
54-
image: quay.io/k8scsi/csi-resizer:v1.0.1
53+
image: k8s.gcr.io/sig-storage/csi-resizer:v1.2.0
5554
args:
56-
- --v=5
5755
- --csi-address=/var/run/shared-tmpfs/csi.sock
5856
- --leader-election
5957
imagePullPolicy: "IfNotPresent"

manifests/container-storage-interface/oci-csi-node-driver.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ spec:
144144
args:
145145
- --csi-address=/csi/csi.sock
146146
- --kubelet-registration-path=/var/lib/kubelet/plugins/blockvolume.csi.oraclecloud.com/csi.sock
147-
image: quay.io/k8scsi/csi-node-driver-registrar:v1.0.2
147+
image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.5.0
148148
securityContext:
149149
privileged: true
150150
lifecycle:
@@ -163,7 +163,7 @@ spec:
163163
args:
164164
- --csi-address=/fss/csi.sock
165165
- --kubelet-registration-path=/var/lib/kubelet/plugins/fss.csi.oraclecloud.com/csi.sock
166-
image: quay.io/k8scsi/csi-node-driver-registrar:v1.0.2
166+
image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.5.0
167167
securityContext:
168168
privileged: true
169169
lifecycle:
@@ -180,8 +180,6 @@ spec:
180180
name: registration-dir
181181
dnsPolicy: ClusterFirst
182182
hostNetwork: true
183-
imagePullSecrets:
184-
- name: image-pull-secret
185183
restartPolicy: Always
186184
schedulerName: default-scheduler
187185
serviceAccount: csi-oci-node-sa

manifests/container-storage-interface/storage-class.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,13 @@ provisioner: blockvolume.csi.oraclecloud.com
66
volumeBindingMode: WaitForFirstConsumer
77
allowVolumeExpansion: true
88
reclaimPolicy: Delete
9+
---
10+
apiVersion: storage.k8s.io/v1
11+
kind: StorageClass
12+
metadata:
13+
name: oci-bv-encrypted
14+
provisioner: blockvolume.csi.oraclecloud.com
15+
parameters:
16+
attachment-type: "paravirtualized"
17+
reclaimPolicy: Delete
18+
volumeBindingMode: WaitForFirstConsumer

pkg/csi/driver/controller.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,8 @@ func (d *ControllerDriver) ControllerPublishVolume(ctx context.Context, req *csi
427427
return nil, status.Errorf(codes.Internal, "Failed to attach volume to node. "+
428428
"The volume is already attached to another node.")
429429
}
430-
if volumeAttached.GetLifecycleState() == core.VolumeAttachmentLifecycleStateAttaching {
430+
if volumeAttached.GetLifecycleState() == core.VolumeAttachmentLifecycleStateAttaching ||
431+
volumeAttached.GetLifecycleState() == core.VolumeAttachmentLifecycleStateAttached {
431432
log.Info("Volume is ATTACHING to node.")
432433
volumeAttached, err = d.client.Compute().WaitForVolumeAttached(ctx, *volumeAttached.GetId())
433434
if err != nil {
@@ -754,8 +755,8 @@ func (d *ControllerDriver) ControllerExpandVolume(ctx context.Context, req *csi.
754755
}
755756

756757
updateVolumeDetails := core.UpdateVolumeDetails{
757-
DisplayName: volume.DisplayName,
758-
SizeInGBs: &newSizeInGB,
758+
DisplayName: volume.DisplayName,
759+
SizeInGBs: &newSizeInGB,
759760
}
760761

761762
volume, err = d.client.BlockStorage().UpdateVolume(ctx, volumeId, updateVolumeDetails)

0 commit comments

Comments
 (0)