Skip to content
Open
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
  •  
  •  
  •  
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.22 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.22:base-rhel9
WORKDIR /

LABEL description="Cluster API Provider OpenStack Controller Manager"
COPY --from=builder /workspace/manager .
COPY ./openshift/manifests ./manifests
COPY openshift/capi-operator-manifests /capi-operator-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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 27 additions & 55 deletions openshift/Makefile
Original file line number Diff line number Diff line change
@@ -1,59 +1,31 @@
# 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_
include provider-version.mk

TOOLS_DIR=../hack/tools
KUSTOMIZE=$(TOOLS_DIR)/bin/kustomize
CONTROLLER_GEN=$(TOOLS_DIR)/bin/controller-gen
GOLANGCI_LINT=$(TOOLS_DIR)/bin/golangci-lint

define manifest_name
$(addsuffix ".yaml",$(addprefix $(manifests_dir)/$(manifests_prefix),$(1)))
endef

manifest_names = 00_credentials-request 04_infrastructure-components
infrastructure_components = kustomize/cluster-capi-configmap/infrastructure-components.yaml

.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
MANIFESTS_GEN := go run ./vendor/github.com/openshift/cluster-capi-operator/manifests-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

.PHONY: ALWAYS
ALWAYS:
verify: verify-ocp-manifests

.PHONY: verify-%
verify-%: ## Ensure no diff after running some other target
$(MAKE) $*
./verify-diff.sh

.PHONY: update-manifests-gen
update-manifests-gen:
cd tools && go get github.com/openshift/cluster-capi-operator/manifests-gen@main github.com/openshift/cluster-capi-operator@main && go mod tidy && go mod vendor

.PHONY: ocp-manifests
ocp-manifests: ## Builds openshift specific manifests
cd tools && $(MANIFESTS_GEN) \
--manifests-path "../capi-operator-manifests" \
--kustomize-dir "../../openshift" \
--name cluster-api-provider-openstack \
--install-order 20 \
--attribute type=infrastructure \
--attribute version="${PROVIDER_VERSION}" \
--self-image-ref registry.ci.openshift.org/openshift:openstack-cluster-api-controllers \
--platform OpenStack \
--protect-cluster-resource openstackcluster
Loading