Skip to content

Commit 7b28c49

Browse files
committed
build: refactor the container build for multi-arch ppc64le
Signed-off-by: Paul Bastide <[email protected]>
1 parent baeeed1 commit 7b28c49

File tree

11 files changed

+117
-39
lines changed

11 files changed

+117
-39
lines changed

.github/workflows/publish.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
with:
7979
context: .
8080
platforms: linux/ppc64le
81-
file: Dockerfile
81+
file: build/Containerfile-build
8282
push: ${{ github.event_name != 'pull_request' }}
8383
tags: ${{ steps.meta.outputs.tags }}
8484
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
!/.gitignore
33

44
#binaries
5-
bin
6-
power-dra-kubeletplugin
5+
bin/*
6+
**/power-dra-kubeletplugin*
77

88
!*.go
99
!go.sum

Dockerfile

Lines changed: 0 additions & 28 deletions
This file was deleted.

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ include $(CURDIR)/versions.mk
1313
# Go Targets
1414

1515
build: fmt vet
16-
GOOS=linux GOARCH=$(ARCH) go build -o bin/power-dra-driver cmd/power-dra-driver/main.go
16+
GOOS=linux GOARCH=$(ARCH) go build -o bin/power-dra-kubeletplugin cmd/power-dra-kubeletplugin/*.go
1717

1818
controller-gen: ## Download controller-gen locally if necessary.
1919
ifeq (, $(shell which controller-gen))
@@ -80,3 +80,9 @@ image-build: image-build
8080
image-push:
8181
$(info push Container image...)
8282
$(CONTAINER_RUNTIME) push $(REGISTRY)/$(REPOSITORY):$(TAG)
83+
84+
.PHONY: image-ci
85+
image-ci: build
86+
$(CONTAINER_RUNTIME) buildx build \
87+
-t $(REGISTRY)/$(REPOSITORY):$(TAG) \
88+
--platform linux/$(ARCH) -f build/Containerfile-build .

api/powervs-openshift-ipi.cis.ibm.net/resource/gpu/v1alpha1/validate.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (d TimeSliceInterval) Validate() error {
4040

4141
// Validate ensures that TimeSlicingConfig has a valid set of values.
4242
func (c *TimeSlicingConfig) Validate() error {
43-
return c.Interval.Validate()
43+
return c.Interval.Validate()
4444
}
4545

4646
// Validate ensures that SpacePartitioningConfig has a valid set of values.
@@ -67,8 +67,8 @@ func (s *GpuSharing) Validate() error {
6767

6868
// Validate ensures that GpuConfig has a valid set of values.
6969
func (c *GpuConfig) Validate() error {
70-
if c.Sharing == nil {
71-
return fmt.Errorf("no sharing strategy set")
72-
}
73-
return c.Sharing.Validate()
70+
if c.Sharing == nil {
71+
return fmt.Errorf("no sharing strategy set")
72+
}
73+
return c.Sharing.Validate()
7474
}

build/Containerfile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
FROM registry.access.redhat.com/ubi9/ubi:9.4 as builder
2+
USER root
3+
WORKDIR /workspace
4+
5+
# From https://github.com/openshift/oc-mirror/blob/main/Dockerfile#L8C1-L20C2
6+
# DNF Package Install List
7+
ARG DNF_LIST="\
8+
jq \
9+
tar \
10+
gcc \
11+
make \
12+
git \
13+
gpgme-devel \
14+
libassuan-devel \
15+
wget \
16+
pigz \
17+
procps-ng \
18+
util-linux \
19+
"
20+
21+
RUN set -ex \
22+
&& ARCH=$(arch | sed 's|x86_64|amd64|g' | sed 's|aarch64|arm64|g') \
23+
&& dnf install -y --nodocs --setopt=install_weak_deps=false ${DNF_LIST} \
24+
&& dnf clean all -y \
25+
&& GO_VERSION=go1.23.4 \
26+
&& curl -sL https://golang.org/dl/${GO_VERSION}.linux-${ARCH}.tar.gz \
27+
| tar xzvf - --directory /usr/local/ \
28+
&& /usr/local/go/bin/go version \
29+
&& ln -f /usr/local/go/bin/go /usr/bin/go
30+
31+
# Link gcc to /usr/bin/s390x-linux-gnu-gcc as go requires it on s390x
32+
RUN [ "$(arch)" == "s390x" ] \
33+
&& ln /usr/bin/gcc /usr/bin/s390x-linux-gnu-gcc \
34+
|| echo "Not running on s390x, skip linking gcc binary"
35+
36+
ENV GOROOT=/usr/local/go
37+
ENV PATH="/root/platform/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin/$GOROOT/bin"
38+
39+
COPY . .
40+
41+
RUN ARCH=$(arch | sed 's|x86_64|amd64|g' | sed 's|aarch64|arm64|g') \
42+
CGO_ENABLED=1 \
43+
CGO_CFLAGS=-I/usr/include \
44+
CGO_LDFLAGS="-L/lib64" GOOS=linux \
45+
go build ${BUILD_FLAGS} -tags strictfipsruntime -a -o bin/power-dra-kubeletplugin ./cmd/power-dra-kubeletplugin
46+
47+
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.4
48+
49+
LABEL io.k8s.display-name="IBM Power DRA Driver"
50+
LABEL name="IBM Power DRA Driver"
51+
LABEL vendor="IBM"
52+
LABEL version="1.0.0"
53+
LABEL release="N/A"
54+
LABEL summary="Automate the management and monitoring of addition of specific devices to a Pod."
55+
LABEL description="Automate the management and monitoring of addition of specific devices to a Pod."
56+
57+
RUN microdnf -y update && microdnf install util-linux -y && microdnf clean all
58+
WORKDIR /
59+
60+
COPY ./build/entrypoint.sh /
61+
COPY --from=builder /workspace/bin/power-dra-kubeletplugin /opt/power-dra/bin/
62+
63+
ENTRYPOINT ["/entrypoint.sh"]

build/Containerfile-build

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.4
2+
3+
LABEL io.k8s.display-name="IBM Power DRA Driver"
4+
LABEL name="IBM Power DRA Driver"
5+
LABEL vendor="IBM"
6+
LABEL version="1.0.0"
7+
LABEL release="N/A"
8+
LABEL summary="Automate the management and monitoring of addition of specific devices to a Pod."
9+
LABEL description="Automate the management and monitoring of addition of specific devices to a Pod."
10+
11+
RUN microdnf -y update && microdnf install util-linux findutils -y && microdnf clean all
12+
WORKDIR /
13+
14+
COPY ./build/entrypoint.sh /
15+
COPY bin/* /opt/power-dra/bin/
16+
17+
ENTRYPOINT ["/entrypoint.sh"]

build/entrypoint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
set -e
4+
exec /opt/power-dra/bin/power-dra-kubeletplugin $@

deployments/helm/power-dra-driver/templates/kubeletplugin.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ spec:
5555
# Simulated number of devices the driver will to have.
5656
- name: NUM_DEVICES
5757
value: "8"
58+
- name: GRPC_GO_LOG_VERBOSITY_LEVEL
59+
value: "99"
60+
- name: GRPC_GO_LOG_SEVERITY_LEVEL
61+
value: "info"
5862
volumeMounts:
5963
- name: plugins-registry
6064
mountPath: /var/lib/kubelet/plugins_registry

deployments/helm/power-dra-driver/values.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,16 @@ kubeletPlugin:
5959
plugin:
6060
securityContext:
6161
privileged: true
62+
capabilities:
63+
add:
64+
- CAP_SYS_ADMIN
65+
- CAP_FOWNER
66+
- NET_ADMIN
67+
- SYS_ADMIN
68+
drop:
69+
- ALL
70+
runAsUser: 0
71+
runAsNonRoot: false
72+
readOnlyRootFilesystem: false
73+
allowPrivilegeEscalation: true
6274
resources: {}

0 commit comments

Comments
 (0)