From bf4c5863cf658fab02376a817562dd33b88745cd Mon Sep 17 00:00:00 2001 From: Jack Henschel <jack.henschel@cern.ch> Date: Sat, 26 Mar 2022 10:45:50 +0100 Subject: [PATCH] [cern] Add custom CERN platform type --- .gitlab-ci.yml | 3 +++ Dockerfile | 1 + README.md | 34 ++++++++++++++++++++++++++++++++++ pkg/operator/config.go | 4 ++++ 4 files changed, 42 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000..6bbc700a5 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,3 @@ +include: + - project: 'paas-tools/infrastructure-ci' + file: 'docker-images-ci-templates/DockerImages.gitlab-ci.yml' diff --git a/Dockerfile b/Dockerfile index 93c5a00e2..d3b58e8c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM registry.ci.openshift.org/openshift/release:golang-1.17 AS builder WORKDIR /go/src/github.com/openshift/machine-api-operator COPY . . +ENV VERSION_OVERRIDE=v0.0.1-cern RUN NO_DOCKER=1 make build FROM registry.ci.openshift.org/openshift/origin-v4.0:base diff --git a/README.md b/README.md index 31b1f3132..cfe28d154 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,37 @@ +# CERN modifications + +For [various reasons](https://okd-internal.docs.cern.ch/design/cern-cloud-cluster-deployment/), we deploy our OpenShift clusters with infrastructure platform type set to 'None' instead of 'OpenStack'. +However, we still want some behaviors that come when setting the platform type to 'OpenStack', e.g. the automatic deployment of [machine-api-controllers](https://gitlab.cern.ch/paas-tools/okd4-deployment/machine-api-operator). +Thus, this repository contains patches that map the 'None' platform type to 'OpenStack' for our use-cases. + +The Gitlab repository is configured to automatically mirror the [upstream machine-api-operator repository](https://github.com/openshift/machine-api-operator). + +Use the following workflow to port our custom patches to a new release: + +```sh +# Make sure your repo is up-to-date +git fetch origin +# Check out the pristine upstream release +git checkout origin/release-4.x +# Push a new branch with the pristine upstream release +git checkout -b cern-4.x +git push origin cern-4.x +# Create a new branch for development +git checkout -b cern-4.x-dev +``` + +Then, locate the latest patches that have been made by us. +This can be done by checking out an old release branch (e.g. `cern-4.8`) and looking at the commits prefixed with `[cern]`. + +``` +git log origin/cern-4.8 +git cherry-pick [CERN_PATCH_REFS] +``` + +At this point, you might need to resolve the merge conflicts (*fingers crossed*). +Afterwards, commit your changes with a `[cern]` prefix and push them to the dev branch. +Finally, create a merge request from `cern-4.x-dev` to `cern-4.x` so someone else can review your changes. + # Machine API Operator The Machine API Operator manages the lifecycle of specific purpose CRDs, controllers and RBAC objects that extend the Kubernetes API. diff --git a/pkg/operator/config.go b/pkg/operator/config.go index 53fe19d08..5a2ed627b 100644 --- a/pkg/operator/config.go +++ b/pkg/operator/config.go @@ -57,6 +57,10 @@ type Images struct { func getProviderFromInfrastructure(infra *configv1.Infrastructure) (configv1.PlatformType, error) { if infra.Status.PlatformStatus != nil { if infra.Status.PlatformStatus.Type != "" { + if infra.Status.PlatformStatus.Type == configv1.NonePlatformType { + // Map cloud platform 'None' to 'OpenStack' for CERN Cloud + return configv1.OpenStackPlatformType, nil + } return infra.Status.PlatformStatus.Type, nil } } -- GitLab