Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
45 changes: 9 additions & 36 deletions Dockerfile.rhel
Original file line number Diff line number Diff line change
@@ -1,45 +1,18 @@
# Copyright 2019 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Build the manager binary
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.24-openshift-4.21 AS builder
WORKDIR /workspace

# Run this with docker build --build_arg goproxy=$(go env GOPROXY) to override the goproxy
ARG goproxy=https://proxy.golang.org
ENV GOPROXY=$goproxy

# Copy the sources
COPY ./ ./

# Build
ARG ARCH
ARG ldflags

WORKDIR /workspace
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} \
go build -ldflags "${ldflags} -extldflags '-static'" \
-o manager
COPY . .
RUN CGO_ENABLED=0 GOOS=${GOOS} GOPROXY=${GOPROXY} go build \
-ldflags "${LDFLAGS} -extldflags '-static'" \
-o manager \
main.go

# Production image
FROM registry.ci.openshift.org/ocp/4.21:base-rhel9
WORKDIR /

LABEL description="Cluster API Provider OpenStack Controller Manager"
COPY --from=builder /workspace/manager .
COPY ./openshift/manifests ./manifests
COPY ./openshift/manifests /manifests

# Use uid of nonroot user (65532) because kubernetes expects numeric user when applying pod security policies
USER 65532
ENTRYPOINT ["/manager"]

LABEL io.openshift.release.operator true
LABEL io.openshift.release.operator=true
81 changes: 17 additions & 64 deletions openshift/Makefile
Original file line number Diff line number Diff line change
@@ -1,69 +1,22 @@
# Copyright 2023 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
BIN_DIR := bin
TOOLS_DIR := tools

manifests_dir ?= ./manifests
manifests_prefix ?= 0000_30_cluster-api-provider-openstack_
$(RELEASE_DIR):
mkdir -p $(RELEASE_DIR)/

TOOLS_DIR=../hack/tools
KUSTOMIZE=$(TOOLS_DIR)/bin/kustomize
CONTROLLER_GEN=$(TOOLS_DIR)/bin/controller-gen
GOLANGCI_LINT=$(TOOLS_DIR)/bin/golangci-lint
MANIFESTS_GEN := go run ./vendor/github.com/openshift/cluster-capi-operator/manifests-gen/

define manifest_name
$(addsuffix ".yaml",$(addprefix $(manifests_dir)/$(manifests_prefix),$(1)))
endef
.PHONY: check-env
check-env:
ifndef PROVIDER_VERSION
$(error PROVIDER_VERSION is undefined)
endif

manifest_names = 00_credentials-request 04_infrastructure-components
infrastructure_components = kustomize/cluster-capi-configmap/infrastructure-components.yaml
.PHONY: update-manifests-gen
update-manifests-gen:
cd tools && go get github.com/openshift/cluster-capi-operator/manifests-gen && go mod tidy && go mod vendor

.PHONY: generate
generate: $(foreach m,$(manifest_names),$(call manifest_name,$(m)))

$(call manifest_name,00_credentials-request): $(KUSTOMIZE) ALWAYS | $(manifests_dir)
$(KUSTOMIZE) build kustomize/credentials-request > $@

$(infrastructure_components): $(KUSTOMIZE) ALWAYS
$(KUSTOMIZE) build kustomize/infrastructure-components > $@

$(call manifest_name,04_infrastructure-components): $(KUSTOMIZE) $(infrastructure_components) ALWAYS | $(manifests_dir)
$(KUSTOMIZE) build kustomize/cluster-capi-configmap > $@

$(manifests_dir):
mkdir -p $@

$(KUSTOMIZE):
$(MAKE) -C $(TOOLS_DIR) bin/kustomize

$(CONTROLLER_GEN):
$(MAKE) -C $(TOOLS_DIR) bin/controller-gen

.PHONY: verify
verify: generate
@if !(git diff --quiet HEAD); then \
git diff; \
echo "generated files are out of date, run make generate"; exit 1; \
fi

# FIXME(stephenfin): Remove the CI job that relies on this: all logic has moved to CCAPIO now
.PHONY: test
test:
echo "done"

# FIXME(stephenfin): Remove this once we've reworked the CI job that relies on this to call the script directly
.PHONY: e2e
e2e:
./e2e-tests.sh

.PHONY: ALWAYS
ALWAYS:
.PHONY: ocp-manifests
ocp-manifests: $(RELEASE_DIR) check-env ## Builds openshift specific manifests.
# Generate provider manifests.
cd tools && $(MANIFESTS_GEN) --provider-name "openstack" --provider-type "InfrastructureProvider" --provider-version "${PROVIDER_VERSION}" --base-path "../../" --manifests-path "../manifests"
Loading