Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ _artifacts

# Goreleaser
dist

# Tilt
.tiltbuild/
51 changes: 33 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ KUBEBUILDER_VERSION ?= 2.3.1
# default install location for kubebuilder; can be placed elsewhere
KUBEBUILDER_DIR ?= /usr/local/kubebuilder
KUBEBUILDER ?= $(KUBEBUILDER_DIR)/bin/kubebuilder
CONTROLLER_GEN_VERSION ?= v0.3.0
CONTROLLER_GEN=$(GOBIN)/controller-gen

CERTMANAGER_URL ?= https://github.com/jetstack/cert-manager/releases/download/v0.14.1/cert-manager.yaml

Expand All @@ -56,6 +54,9 @@ REPO_URL ?= https://github.com/packethost/cluster-api-provider-packet
BUILDARCH ?= $(shell uname -m)
BUILDOS ?= $(shell uname -s | tr A-Z a-z)

# Allow overriding the imagePullPolicy
PULL_POLICY ?= Always

E2E_FOCUS := "functional tests"

# Directories.
Expand All @@ -64,9 +65,21 @@ TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
BIN_DIR := bin
TEST_DIR := test
TEST_E2E_DIR := $(TEST_DIR)/e2e
ENVSUBST_BIN := bin/envsubst
ENVSUBST := $(TOOLS_DIR)/$(ENVSUBST_BIN)

# Binaries.
KUSTOMIZE := $(TOOLS_BIN_DIR)/kustomize
KUSTOMIZE := $(abspath $(TOOLS_BIN_DIR)/kustomize)
CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/controller-gen)
ENVSUBST := $(abspath $(TOOLS_BIN_DIR)/envsubst)

envsubst: $(ENVSUBST) ## Build a local copy of envsubst.
$(ENVSUBST): $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR) && go build -tags=tools -o $(ENVSUBST_BIN) github.com/drone/envsubst/cmd/envsubst

controller-gen: $(CONTROLLER_GEN) ## Build a local copy of controller-gen.
$(CONTROLLER_GEN): $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR) && go build -tags=tools -o $(BIN_DIR)/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen

kustomize: $(KUSTOMIZE)
$(KUSTOMIZE): $(TOOLS_DIR)/go.mod # Build kustomize from tools folder.
Expand Down Expand Up @@ -120,8 +133,6 @@ GO ?= GO111MODULE=on CGO_ENABLED=0 go

# Image URL to use all building/pushing image targets
IMG ?= packethost/cluster-api-provider-packet:latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -245,8 +256,15 @@ deploy: crds
$(KUSTOMIZE) build config/release | kubectl apply -f -

# Generate manifests e.g. CRD, RBAC etc.
crds: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/resources/crd/bases
crds: $(CONTROLLER_GEN)
$(CONTROLLER_GEN) \
paths=./api/... \
paths=./controllers/... \
crd:crdVersions=v1 \
rbac:roleName=manager-role \
output:crd:dir=./config/crd/bases \
output:webhook:dir=./config/webhook \
webhook

# Run go fmt against code
fmt:
Expand All @@ -257,7 +275,7 @@ vet:
go vet ./...

# Generate code
generate: controller-gen
generate: $(CONTROLLER_GEN)
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

## make the images for all supported ARCH
Expand Down Expand Up @@ -297,14 +315,6 @@ sub-push-%:
push:
docker push $(IMAGENAME)

# find or download controller-gen
# download controller-gen if necessary
# version must be at least the given version
.PHONY: $(CONTROLLER_GEN)
controller-gen: $(CONTROLLER_GEN)
$(CONTROLLER_GEN):
scripts/controller-gen.sh $@ $(CONTROLLER_GEN_VERSION)

## generate a cluster using clusterctl and setting defaults
cluster:
./scripts/generate-cluster.sh
Expand All @@ -328,10 +338,10 @@ manifest: kustomize semver release-manifests release-clusterctl release-cluster-

release-manifests: semver $(RELEASE_MANIFEST) $(RELEASE_METADATA) $(RELEASE_CLUSTER_TEMPLATE)
release-version:
KUSTOMIZE_ENABLE_ALPHA_COMMANDS=true $(KUSTOMIZE) cfg set config/release image-tag $(VERSION)
KUSTOMIZE_ENABLE_ALPHA_COMMANDS=true $(KUSTOMIZE) cfg set config image-tag $(VERSION)

$(RELEASE_MANIFEST): $(RELEASE_DIR) release-version ## Builds the manifests to publish with a release
$(KUSTOMIZE) build config/release > $@
$(KUSTOMIZE) build config > $@

$(RELEASE_METADATA): semver $(RELEASE_DIR)
cp $(METADATA_YAML) $@
Expand Down Expand Up @@ -389,3 +399,8 @@ cluster-init-manual: core managerless release
# because of dependencies, this is allowed to fail once or twice
kubectl apply -f $(COREPATH) || kubectl apply -f $(COREPATH) || kubectl apply -f $(COREPATH)
kubectl apply -f $(FULL_MANAGERLESS_MANIFEST)

.PHONY: modules
modules: ## Runs go mod to ensure modules are up to date.
go mod tidy
cd $(TOOLS_DIR); go mod tidy
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# The following manifests contain a self-signed issuer CR and a certificate CR.
# More document can be found at https://docs.cert-manager.io
# WARNING: Targets CertManager 0.11 check https://docs.cert-manager.io/en/latest/tasks/upgrading/index.html for
# breaking changes
apiVersion: cert-manager.io/v1alpha2
kind: Issuer
metadata:
Expand All @@ -13,7 +11,7 @@ spec:
apiVersion: cert-manager.io/v1alpha2
kind: Certificate
metadata:
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml
namespace: system
spec:
# $(SERVICE_NAME) and $(SERVICE_NAMESPACE) will be substituted by kustomize
Expand All @@ -23,4 +21,4 @@ spec:
issuerRef:
kind: Issuer
name: selfsigned-issuer
secretName: webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize
secretName: $(SERVICE_NAME)-cert # this secret will not be prefixed, since it's not managed by kustomize
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
resources:
- certificate.yaml

configurations:
- kustomizeconfig.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# This configuration is for teaching kustomize how to update name ref and var substitution
# This configuration is for teaching kustomize how to update name ref and var substitution
nameReference:
- kind: Issuer
group: cert-manager.io
fieldSpecs:
- kind: Certificate
group: cert-manager.io
path: spec/issuerRef/name

varReference:
- kind: Certificate
group: cert-manager.io
path: spec/commonName
- kind: Certificate
group: cert-manager.io
path: spec/dnsNames
- kind: Certificate
group: cert-manager.io
path: spec/secretName
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.9
creationTimestamp: null
name: packetclusters.infrastructure.cluster.x-k8s.io
spec:
group: infrastructure.cluster.x-k8s.io
names:
kind: PacketCluster
listKind: PacketClusterList
plural: packetclusters
singular: packetcluster
scope: Namespaced
versions:
- name: v1alpha3
schema:
openAPIV3Schema:
description: PacketCluster is the Schema for the packetclusters API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: PacketClusterSpec defines the desired state of PacketCluster
properties:
controlPlaneEndpoint:
description: ControlPlaneEndpoint represents the endpoint used to
communicate with the control plane.
properties:
host:
description: The hostname on which the API server is serving.
type: string
port:
description: The port on which the API server is serving.
format: int32
type: integer
required:
- host
- port
type: object
facility:
description: Facility represents the Packet facility for this cluster
type: string
projectID:
description: ProjectID represents the Packet Project where this cluster
will be placed into
type: string
required:
- projectID
type: object
status:
description: PacketClusterStatus defines the observed state of PacketCluster
properties:
ready:
description: Ready denotes that the cluster (infrastructure) is ready.
type: boolean
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Loading