Skip to content

Commit b60cb4f

Browse files
dkoshkinjimmidyson
authored andcommitted
build: minor changes to make boilerplate buildable
GOOS=linux make build IMG=dkoshkin/capi-runtime-extensions:latest make docker-build make deploy
1 parent e0ea453 commit b60cb4f

File tree

10 files changed

+876
-67
lines changed

10 files changed

+876
-67
lines changed

Dockerfile

Lines changed: 4 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,12 @@
11
# syntax=docker/dockerfile:1.4
22

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-
# Build the extension binary
18-
# Run this with docker build --build-arg builder_image=<golang:x.y.z>
19-
ARG builder_image
20-
21-
# Ignore Hadolint rule "Always tag the version of an image explicitly."
22-
# It's an invalid finding since the image is explicitly set in the Makefile.
23-
# https://github.com/hadolint/hadolint/wiki/DL3006
24-
# hadolint ignore=DL3006
25-
FROM ${builder_image} as builder
26-
WORKDIR /workspace
27-
28-
# Run this with docker build --build-arg goproxy=$(go env GOPROXY) to override the goproxy
29-
ARG goproxy=https://proxy.golang.org
30-
# Run this with docker build --build-arg package=./controlplane/kubeadm or --build-arg package=./bootstrap/kubeadm
31-
ENV GOPROXY=$goproxy
32-
33-
# Copy the Go Modules manifests
34-
COPY go.mod go.mod
35-
COPY go.sum go.sum
36-
37-
# Cache deps before building and copying source so that we don't need to re-download as much
38-
# and so that source changes don't invalidate our downloaded layer
39-
RUN --mount=type=cache,target=/go/pkg/mod \
40-
go mod download
41-
42-
# Copy the sources
43-
COPY ./ ./
44-
45-
# Cache the go build into the the Go’s compiler cache folder so we take benefits of compiler caching across docker build calls
46-
RUN --mount=type=cache,target=/root/.cache/go-build \
47-
--mount=type=cache,target=/go/pkg/mod \
48-
go build .
49-
50-
# Build
51-
ARG package=.
52-
ARG ARCH
53-
ARG ldflags
54-
55-
# Essentially, change directories into test extension
56-
WORKDIR /workspace/test/extension
57-
58-
# Do not force rebuild of up-to-date packages (do not use -a) and use the compiler cache folder
59-
RUN --mount=type=cache,target=/root/.cache/go-build \
60-
--mount=type=cache,target=/go/pkg/mod \
61-
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} \
62-
go build -trimpath -ldflags "${ldflags} -extldflags '-static'" \
63-
-o /workspace/extension ${package}
3+
# Copyright 2023 D2iQ, Inc. All rights reserved.
4+
# SPDX-License-Identifier: Apache-2.0
645

656
# Production image
667
FROM gcr.io/distroless/static:nonroot
678
WORKDIR /
68-
COPY --from=builder /workspace/extension .
9+
COPY /bin/manager .
6910
# Use uid of nonroot user (65532) because kubernetes expects numeric user when applying pod security policies
7011
USER 65532
71-
ENTRYPOINT ["/extension"]
12+
ENTRYPOINT ["/manager"]

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# CAPI Runtime Extensions Server
2+
3+
See [upstream documentation](https://cluster-api.sigs.k8s.io/tasks/experimental-features/runtime-sdk/index.html).

config/default/extension.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ spec:
1515
spec:
1616
containers:
1717
- command:
18-
- /extension
18+
- /manager
1919
image: controller:latest
2020
name: extension
2121
terminationGracePeriodSeconds: 10

config/default/extension_image_patch.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ spec:
66
template:
77
spec:
88
containers:
9-
- image: gcr.io/k8s-staging-cluster-api/test-extension:main
9+
# FIXME replace with d2iq image
10+
- image: dkoshkin/capi-runtime-extensions:latest
1011
name: extension

config/default/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ vars:
2222
objref:
2323
kind: Service
2424
version: v1
25-
name: webhook-service
25+
name: test-extension-webhook-service
2626

2727
configurations:
2828
- kustomizeconfig.yaml

config/default/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
kind: Service
33
metadata:
4-
name: webhook-service
4+
name: test-extension-webhook-service
55
spec:
66
ports:
77
- port: 443

go.mod

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
module github.com/d2iq-labs/capi-runtime-extensions
2+
3+
go 1.19
4+
5+
require (
6+
github.com/spf13/pflag v1.0.5
7+
k8s.io/component-base v0.25.0
8+
k8s.io/klog/v2 v2.90.0
9+
sigs.k8s.io/cluster-api v1.3.3
10+
sigs.k8s.io/controller-runtime v0.13.1
11+
)
12+
13+
require (
14+
github.com/beorn7/perks v1.0.1 // indirect
15+
github.com/blang/semver v3.5.1+incompatible // indirect
16+
github.com/cespare/xxhash/v2 v2.1.2 // indirect
17+
github.com/davecgh/go-spew v1.1.1 // indirect
18+
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
19+
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
20+
github.com/fsnotify/fsnotify v1.6.0 // indirect
21+
github.com/go-logr/logr v1.2.3 // indirect
22+
github.com/go-openapi/jsonpointer v0.19.5 // indirect
23+
github.com/go-openapi/jsonreference v0.20.0 // indirect
24+
github.com/go-openapi/swag v0.22.3 // indirect
25+
github.com/gogo/protobuf v1.3.2 // indirect
26+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
27+
github.com/golang/protobuf v1.5.2 // indirect
28+
github.com/google/gnostic v0.6.9 // indirect
29+
github.com/google/go-cmp v0.5.9 // indirect
30+
github.com/google/gofuzz v1.2.0 // indirect
31+
github.com/google/uuid v1.3.0 // indirect
32+
github.com/imdario/mergo v0.3.13 // indirect
33+
github.com/inconshreveable/mousetrap v1.0.1 // indirect
34+
github.com/josharian/intern v1.0.0 // indirect
35+
github.com/json-iterator/go v1.1.12 // indirect
36+
github.com/mailru/easyjson v0.7.7 // indirect
37+
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
38+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
39+
github.com/modern-go/reflect2 v1.0.2 // indirect
40+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
41+
github.com/pkg/errors v0.9.1 // indirect
42+
github.com/prometheus/client_golang v1.14.0 // indirect
43+
github.com/prometheus/client_model v0.3.0 // indirect
44+
github.com/prometheus/common v0.37.0 // indirect
45+
github.com/prometheus/procfs v0.8.0 // indirect
46+
github.com/spf13/cobra v1.6.1 // indirect
47+
golang.org/x/net v0.4.0 // indirect
48+
golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1 // indirect
49+
golang.org/x/sys v0.3.0 // indirect
50+
golang.org/x/term v0.3.0 // indirect
51+
golang.org/x/text v0.5.0 // indirect
52+
golang.org/x/time v0.3.0 // indirect
53+
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
54+
google.golang.org/appengine v1.6.7 // indirect
55+
google.golang.org/protobuf v1.28.1 // indirect
56+
gopkg.in/inf.v0 v0.9.1 // indirect
57+
gopkg.in/yaml.v2 v2.4.0 // indirect
58+
gopkg.in/yaml.v3 v3.0.1 // indirect
59+
k8s.io/api v0.25.0 // indirect
60+
k8s.io/apiextensions-apiserver v0.25.0 // indirect
61+
k8s.io/apimachinery v0.25.0 // indirect
62+
k8s.io/client-go v0.25.0 // indirect
63+
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
64+
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect
65+
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
66+
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
67+
sigs.k8s.io/yaml v1.3.0 // indirect
68+
)

0 commit comments

Comments
 (0)