Skip to content

Commit 1dcd1b0

Browse files
authored
Added template to use powervs cloud provider (#614)
1 parent 7856be6 commit 1dcd1b0

File tree

7 files changed

+647
-0
lines changed

7 files changed

+647
-0
lines changed

docs/book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- [Power VS Cluster](./topics/powervs/index.md)
1313
- [Prerequisites](./topics/powervs/prerequisites.md)
1414
- [Creating a cluster](./topics/powervs/creating-a-cluster.md)
15+
- [Creating a cluster with External Cloud Provider](./topics/powervs/external-cloud-provider.md)
1516
- [Developer Guide](./developer/index.md)
1617
- [Rapid iterative development with Tilt](./developer/tilt.md)
1718
- [Guide for API conversions](./developer/conversion.md)

docs/book/src/topics/powervs/creating-a-cluster.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ following the steps below.
3434

3535
2. Use clusterctl to render the yaml through templates and deploy the cluster
3636

37+
**Note:** To deploy workload cluster with Power VS cloud controller manager which is currently in experimental stage follow [these](/topics/powervs/external-cloud-provider.html) steps.
38+
3739
**Note:** the `IBMPOWERVS_IMAGE_ID` value below should reflect the ID of the custom qcow2 image, the `kubernetes-version` value below should reflect the kubernetes version of the custom qcow2 image.
3840

3941
```console
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# IBM Power VS External Cloud Provider
2+
## This feature currently in experimental stage
3+
4+
## Steps
5+
6+
- To deploy a Power VS workload cluster with IBM Power VS external [cloud provider](https://kubernetes.io/docs/concepts/architecture/cloud-controller/), create a cluster configuration with the [external cloud provider template](https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/blob/main/templates/cluster-template-powervs-cloud-provider.yaml)
7+
- The [external cloud provider template](https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/blob/main/templates/cluster-template-powervs-cloud-provider.yaml) will use [clusterresourceset](https://cluster-api.sigs.k8s.io/tasks/experimental-features/cluster-resource-set.html) and will create the necessary config map, secret and roles to run the cloud controller manager
8+
- As a prerequisite set the `powervs-provider-id-fmt` [flag](https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/blob/64c9e1d17f1733c721f45a559edba3f4b712bcb0/main.go#L220) with value v2
9+
10+
### Deploy Power VS cluster with IBM Power VS cloud provider
11+
12+
```
13+
IBMPOWERVS_SSHKEY_NAME="my-pub-key" \
14+
IBMPOWERVS_VIP="192.168.151.22" \
15+
IBMPOWERVS_VIP_EXTERNAL="158.175.162.22" \
16+
IBMPOWERVS_VIP_CIDR="29" \
17+
IBMPOWERVS_IMAGE_NAME="capibm-powervs-centos-8-1-22-4" \
18+
IBMPOWERVS_SERVICE_INSTANCE_ID="7845d372-d4e1-46b8-91fc-41051c984601" \
19+
IBMPOWERVS_NETWORK_NAME="capi-test-3" \
20+
IBMACCOUNT_ID="ibm-accountid" \
21+
IBMPOWERVS_REGION="powervs-region" \
22+
IBMPOWERVS_ZONE="powervs-zone" \
23+
BASE64_API_KEY=$(echo -n $IBMCLOUD_API_KEY | base64) \
24+
clusterctl generate cluster ibm-powervs-1 --kubernetes-version v1.22.4 \
25+
--target-namespace default \
26+
--control-plane-machine-count=3 \
27+
--worker-machine-count=1 \
28+
--from ./cluster-template-powervs-cloud-provider.yaml | kubectl apply -f -
29+
```
30+
31+
When the cluster is created with above parameters, The IBM Power VS cloud provider will
32+
1. Initialize the node by fetching appropriate VM information such as IP, zone, region from Power Cloud.

hack/ccm/Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# syntax=docker/dockerfile:1.1-experimental
2+
3+
# Copyright 2022 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
ARG GOLANG_IMAGE=golang:1.17
18+
ARG TARGETPLATFORM=linux/amd64
19+
ARG ARCH=amd64
20+
21+
# Build vpcctl binary
22+
FROM ${GOLANG_IMAGE} as vpc-builder
23+
ARG ARCH
24+
ARG VPC_CONTROLLER_COMMIT
25+
WORKDIR /build
26+
RUN git clone https://github.com/openshift/cloud-provider-vpc-controller
27+
RUN cd cloud-provider-vpc-controller/cmd && git checkout $VPC_CONTROLLER_COMMIT && CGO_ENABLED=0 GOARCH=$ARCH go build \
28+
-ldflags "-s -w" -o /build/vpcctl .
29+
30+
# Build IBM cloud controller manager binary
31+
FROM ${GOLANG_IMAGE} AS ccm-builder
32+
ARG ARCH
33+
ARG POWERVS_CLOUD_CONTROLLER_COMMIT
34+
WORKDIR /build
35+
RUN git clone https://github.com/openshift/cloud-provider-powervs
36+
RUN cd cloud-provider-powervs && git checkout $POWERVS_CLOUD_CONTROLLER_COMMIT && CGO_ENABLED=0 GOARCH=$ARCH go build \
37+
-ldflags "-s -w" -o /build/ibm-cloud-controller-manager .
38+
39+
# Assemble the final image
40+
FROM --platform=$TARGETPLATFORM quay.io/centos/centos:stream8 AS centos-base
41+
LABEL description="IBM PowerVS Cloud Controller Manager"
42+
COPY --from=vpc-builder /build/vpcctl /bin/vpcctl
43+
COPY --from=ccm-builder /build/ibm-cloud-controller-manager /bin/ibm-cloud-controller-manager
44+
ENTRYPOINT [ "/bin/ibm-cloud-controller-manager" ]

hack/ccm/Makefile

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2022 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
REGISTRY=gcr.io/k8s-staging-capi-ibmcloud
16+
IMG=powervs-cloud-controller-manager
17+
18+
# VPC_CONTROLLER_COMMIT can be fetched from here https://github.com/openshift/cloud-provider-vpc-controller/commits/master
19+
VPC_CONTROLLER_COMMIT?=9b99b4e
20+
# POWERVS_CLOUD_CONTROLLER_COMMIT can be fetched from here https://github.com/openshift/cloud-provider-powervs/commits/main
21+
POWERVS_CLOUD_CONTROLLER_COMMIT?=a6bfa07
22+
TAG?=$(VPC_CONTROLLER_COMMIT)_$(POWERVS_CLOUD_CONTROLLER_COMMIT)
23+
24+
build-image-and-push-linux-amd64: init-buildx
25+
{ \
26+
set -e ; \
27+
docker buildx build \
28+
--build-arg TARGETPLATFORM=linux/amd64 --build-arg ARCH=amd64 \
29+
--build-arg VPC_CONTROLLER_COMMIT=$(VPC_CONTROLLER_COMMIT) --build-arg POWERVS_CLOUD_CONTROLLER_COMMIT=$(POWERVS_CLOUD_CONTROLLER_COMMIT)\
30+
-t $(REGISTRY)/$(IMG):$(TAG)_linux_amd64 . --push --target centos-base; \
31+
}
32+
33+
build-image-and-push-linux-ppc64le: init-buildx
34+
{ \
35+
set -e ; \
36+
docker buildx build \
37+
--build-arg TARGETPLATFORM=linux/ppc64le --build-arg ARCH=ppc64le\
38+
--build-arg VPC_CONTROLLER_COMMIT=$(VPC_CONTROLLER_COMMIT) --build-arg POWERVS_CLOUD_CONTROLLER_COMMIT=$(POWERVS_CLOUD_CONTROLLER_COMMIT)\
39+
-t $(REGISTRY)/$(IMG):$(TAG)_linux_ppc64le . --push --target centos-base; \
40+
}
41+
42+
init-buildx:
43+
# Ensure we use a builder that can leverage it (the default on linux will not)
44+
docker buildx rm multiarch-multiplatform-builder
45+
docker buildx create --use --name=multiarch-multiplatform-builder
46+
docker run --rm --privileged multiarch/qemu-user-static --reset --credential yes --persistent yes
47+
# Register gcloud as a Docker credential helper.
48+
# Required for "docker buildx build --push".
49+
gcloud auth configure-docker --quiet
50+
51+
52+
build-and-push-multi-arch: build-image-and-push-linux-amd64 build-image-and-push-linux-ppc64le
53+
docker manifest create --amend $(REGISTRY)/$(IMG):$(TAG) $(REGISTRY)/$(IMG):$(TAG)_linux_amd64 $(REGISTRY)/$(IMG):$(TAG)_linux_ppc64le
54+
docker manifest push -p $(REGISTRY)/$(IMG):$(TAG)

hack/ccm/cloudbuild.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# See https://cloud.google.com/cloud-build/docs/build-config
2+
timeout: 3000s
3+
options:
4+
substitution_option: ALLOW_LOOSE
5+
steps:
6+
- name: 'gcr.io/k8s-testimages/gcb-docker-gcloud:v20210722-085d930'
7+
dir: 'hack/ccm'
8+
entrypoint: make
9+
env:
10+
- PULL_BASE_REF=${_PULL_BASE_REF}
11+
- HOME=/root
12+
args:
13+
- build-and-push-multi-arch
14+
substitutions:
15+
# _GIT_TAG will be filled with a git-based tag for the image, of the form vYYYYMMDD-hash, and
16+
# can be used as a substitution
17+
_GIT_TAG: '12345'
18+
_PULL_BASE_REF: 'dev'

0 commit comments

Comments
 (0)