Skip to content

Commit

Permalink
Merge branch 'main' into fix-aws-hosted
Browse files Browse the repository at this point in the history
  • Loading branch information
kylewuolle authored Jan 7, 2025
2 parents 74f9295 + a2bae4e commit ffcdb58
Show file tree
Hide file tree
Showing 139 changed files with 2,332 additions and 529 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

env:
GO_VERSION: '1.23'
REGISTRY_REPO: 'oci://ghcr.io/mirantis/hmc/charts-ci'
REGISTRY_REPO: 'oci://ghcr.io/k0rdent/kcm/charts-ci'

jobs:
build:
Expand All @@ -31,6 +31,8 @@ jobs:
version: ${{ steps.vars.outputs.version }}
clustername: ${{ steps.vars.outputs.clustername }}
pr: ${{ steps.pr.outputs.result }}
permissions:
packages: write
steps:
- name: Get PR ref
uses: actions/github-script@v7
Expand Down Expand Up @@ -77,11 +79,11 @@ jobs:
uses: docker/build-push-action@v6
with:
build-args: |
LD_FLAGS=-s -w -X github.com/Mirantis/hmc/internal/build.Version=${{ steps.vars.outputs.version }}
LD_FLAGS=-s -w -X github.com/K0rdent/kcm/internal/build.Version=${{ steps.vars.outputs.version }}
context: .
platforms: linux/amd64
tags: |
ghcr.io/mirantis/hmc/controller-ci:${{ steps.vars.outputs.version }}
ghcr.io/k0rdent/kcm/controller-ci:${{ steps.vars.outputs.version }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
Expand Down Expand Up @@ -113,7 +115,7 @@ jobs:
env:
GINKGO_LABEL_FILTER: 'controller'
CLUSTER_DEPLOYMENT_NAME: ${{ needs.build.outputs.clustername }}
IMG: 'ghcr.io/mirantis/hmc/controller-ci:${{ needs.build.outputs.version }}'
IMG: 'ghcr.io/k0rdent/kcm/controller-ci:${{ needs.build.outputs.version }}'
VERSION: ${{ needs.build.outputs.version }}
run: |
make test-e2e
Expand Down Expand Up @@ -163,7 +165,7 @@ jobs:
env:
GINKGO_LABEL_FILTER: 'provider:cloud'
CLUSTER_DEPLOYMENT_NAME: ${{ needs.build.outputs.clustername }}
IMG: 'ghcr.io/mirantis/hmc/controller-ci:${{ needs.build.outputs.version }}'
IMG: 'ghcr.io/k0rdent/kcm/controller-ci:${{ needs.build.outputs.version }}'
VERSION: ${{ needs.build.outputs.version }}
run: |
make test-e2e
Expand Down Expand Up @@ -216,7 +218,7 @@ jobs:
env:
GINKGO_LABEL_FILTER: 'provider:onprem'
CLUSTER_DEPLOYMENT_NAME: ${{ needs.build.outputs.clustername }}
IMG: 'ghcr.io/mirantis/hmc/controller-ci:${{ needs.build.outputs.version }}'
IMG: 'ghcr.io/k0rdent/kcm/controller-ci:${{ needs.build.outputs.version }}'
VERSION: ${{ needs.build.outputs.version }}
run: |
make test-e2e
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
jobs:
release:
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -32,19 +35,19 @@ jobs:
uses: docker/build-push-action@v6
with:
build-args: |
LD_FLAGS=-s -w -X github.com/Mirantis/hmc/internal/build.Version=${{ env.VERSION }} -X github.com/Mirantis/hmc/internal/telemetry.segmentToken=${{ secrets.SEGMENT_TOKEN }}
LD_FLAGS=-s -w -X github.com/K0rdent/kcm/internal/build.Version=${{ env.VERSION }} -X github.com/K0rdent/kcm/internal/telemetry.segmentToken=${{ secrets.SEGMENT_TOKEN }}
context: .
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/mirantis/hmc/controller:${{ env.VERSION }}
ghcr.io/k0rdent/kcm/controller:${{ env.VERSION }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Prepare HMC chart
run: VERSION="${{ env.VERSION }}" make hmc-chart-release
- name: Push charts to GHCR
run: REGISTRY_REPO="oci://ghcr.io/mirantis/hmc/charts" make helm-push
run: REGISTRY_REPO="oci://ghcr.io/k0rdent/kcm/charts" make helm-push

- name: Prepare manifests
run: make hmc-dist-release
Expand All @@ -61,7 +64,7 @@ jobs:

- name: Build airgap bundle
env:
IMG: 'ghcr.io/mirantis/hmc/controller:${{ env.VERSION }}'
IMG: 'ghcr.io/k0rdent/kcm/controller:${{ env.VERSION }}'
run: |
make airgap-package
Expand Down
6 changes: 3 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ issues:
path: (.*_test\.go|test\/|api\/?.*\/.*_types\.go) # ignore tests, and k8s API-specific files
linters:
- govet
- text: "max-public-structs: you have exceeded the maximum number of public struct declarations"
- text: "max-public-structs: you have exceeded the maximum number.*of public struct declarations"
linters:
- revive
path: api/ # the api/ pkgs have lots of structs
Expand Down Expand Up @@ -132,7 +132,7 @@ linters-settings:
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/Mirantis/hmc) # Custom section: groups all imports with the specified Prefix.
- prefix(github.com/K0rdent/kcm) # Custom section: groups all imports with the specified Prefix.
skip-generated: false
gofmt:
# Apply the rewrite rules to the source before reformatting.
Expand Down Expand Up @@ -230,7 +230,7 @@ linters-settings:
- ["call-chain", "loop", "method-call", "recover", "immediate-recover", "return"]
- name: dot-imports
arguments:
- { allowedPackages: ["github.com/onsi/ginkgo/v2","github.com/onsi/gomega"] }
- { allowedPackages: ["github.com/onsi/ginkgo/v2","github.com/onsi/gomega","sigs.k8s.io/controller-runtime/pkg/envtest/komega"] }
- name: duplicated-imports
- name: early-return
- name: empty-block
Expand Down
49 changes: 34 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ templates-generate:
generate-all: generate manifests templates-generate add-license

.PHONY: fmt
fmt: ## Run go fmt against code.
fmt: ## Run 'go fmt' against code.
go fmt ./...

.PHONY: vet
vet: ## Run go vet against code.
vet: ## Run 'go vet' against code.
go vet ./...

.PHONY: tidy
tidy:
tidy: ## Run 'go mod tidy' against code.
go mod tidy

.PHONY: test
Expand All @@ -110,8 +110,8 @@ test: generate-all envtest tidy external-crd ## Run tests.

# Utilize Kind or modify the e2e tests to load the image locally, enabling
# compatibility with other vendors.
.PHONY: test-e2e # Run the e2e tests using a Kind k8s instance as the management cluster.
test-e2e: cli-install
.PHONY: test-e2e
test-e2e: cli-install ## Run the e2e tests using a Kind k8s instance as the management cluster.
@if [ "$$GINKGO_LABEL_FILTER" ]; then \
ginkgo_label_flag="-ginkgo.label-filter=$$GINKGO_LABEL_FILTER"; \
fi; \
Expand All @@ -134,8 +134,11 @@ add-license: addlicense
TEMPLATES_DIR := templates
PROVIDER_TEMPLATES_DIR := $(TEMPLATES_DIR)/provider
export PROVIDER_TEMPLATES_DIR
CLUSTER_TEMPLATES_DIR := $(TEMPLATES_DIR)/cluster
CHARTS_PACKAGE_DIR ?= $(LOCALBIN)/charts
EXTENSION_CHARTS_PACKAGE_DIR ?= $(LOCALBIN)/charts/extensions
K0S_VERSION = $(shell $(YQ) '.k0s.version' $(CLUSTER_TEMPLATES_DIR)/vsphere-standalone-cp/values.yaml)
K0S_AG_IMAGE = k0s-ag-image:$(subst +,-,$(K0S_VERSION))
$(EXTENSION_CHARTS_PACKAGE_DIR): | $(LOCALBIN)
mkdir -p $(EXTENSION_CHARTS_PACKAGE_DIR)
$(CHARTS_PACKAGE_DIR): | $(LOCALBIN)
Expand All @@ -156,8 +159,13 @@ collect-airgap-providers: yq helm clusterctl $(PROVIDER_TEMPLATES_DIR) $(LOCALBI
helm-package: $(CHARTS_PACKAGE_DIR) $(EXTENSION_CHARTS_PACKAGE_DIR) helm collect-airgap-providers
@make $(patsubst %,package-%-tmpl,$(TEMPLATE_FOLDERS))

bundle-images: dev-apply $(IMAGES_PACKAGE_DIR) ## Create a tarball with all images used by HMC.
@BUNDLE_TARBALL=$(IMAGES_PACKAGE_DIR)/hmc-images-$(VERSION).tgz EXTENSIONS_BUNDLE_TARBALL=$(IMAGES_PACKAGE_DIR)/hmc-extension-images-$(VERSION).tgz IMG=$(IMG) KUBECTL=$(KUBECTL) YQ=$(YQ) HELM=$(HELM) NAMESPACE=$(NAMESPACE) TEMPLATES_DIR=$(TEMPLATES_DIR) KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) $(SHELL) $(CURDIR)/scripts/bundle-images.sh
.PHONY: k0s-image
k0s-image:
export DOCKER_BUILDKIT=1
$(CONTAINER_TOOL) build --build-arg K0S_VERSION=$(K0S_VERSION) -t $(K0S_AG_IMAGE) hack/k0s-ag-image

bundle-images: dev-apply $(IMAGES_PACKAGE_DIR) k0s-image ## Create a tarball with all images used by HMC.
@BUNDLE_TARBALL=$(IMAGES_PACKAGE_DIR)/hmc-images-$(VERSION).tgz EXTENSIONS_BUNDLE_TARBALL=$(IMAGES_PACKAGE_DIR)/hmc-extension-images-$(VERSION).tgz IMG=$(IMG) KUBECTL=$(KUBECTL) YQ=$(YQ) HELM=$(HELM) NAMESPACE=$(NAMESPACE) TEMPLATES_DIR=$(TEMPLATES_DIR) KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) K0S_AG_IMAGE=$(K0S_AG_IMAGE) $(SHELL) $(CURDIR)/scripts/bundle-images.sh

airgap-package: bundle-images ## Create a tarball with all images and Helm charts used by HMC, useful for deploying in air-gapped environments.
@TEMPLATES_DIR=$(TEMPLATES_DIR) EXTENSION_CHARTS_PACKAGE_DIR=$(EXTENSION_CHARTS_PACKAGE_DIR) HELM=$(HELM) YQ=$(YQ) $(SHELL) $(CURDIR)/scripts/package-k0s-extensions-helm.sh
Expand All @@ -176,8 +184,8 @@ package-chart-%: lint-chart-%
##@ Build

LD_FLAGS?= -s -w
LD_FLAGS += -X github.com/Mirantis/hmc/internal/build.Version=$(VERSION)
LD_FLAGS += -X github.com/Mirantis/hmc/internal/telemetry.segmentToken=$(SEGMENT_TOKEN)
LD_FLAGS += -X github.com/K0rdent/kcm/internal/build.Version=$(VERSION)
LD_FLAGS += -X github.com/K0rdent/kcm/internal/telemetry.segmentToken=$(SEGMENT_TOKEN)

.PHONY: build
build: generate-all ## Build manager binary.
Expand Down Expand Up @@ -360,8 +368,8 @@ dev-aks-creds: envsubst
dev-openstack-creds: envsubst
@NAMESPACE=$(NAMESPACE) $(ENVSUBST) -no-unset -i config/dev/openstack-credentials.yaml | $(KUBECTL) apply -f -

.PHONY: dev-apply ## Apply the development environment by deploying the kind cluster, local registry and the HMC helm chart.
dev-apply: kind-deploy registry-deploy dev-push dev-deploy dev-templates dev-release
.PHONY: dev-apply
dev-apply: kind-deploy registry-deploy dev-push dev-deploy dev-templates dev-release ## Apply the development environment by deploying the kind cluster, local registry and the HMC helm chart.

.PHONY: test-apply
test-apply: set-hmc-version helm-package dev-deploy dev-templates dev-release
Expand All @@ -370,15 +378,15 @@ test-apply: set-hmc-version helm-package dev-deploy dev-templates dev-release
dev-destroy: kind-undeploy registry-undeploy ## Destroy the development environment by deleting the kind cluster and local registry.

.PHONY: dev-mcluster-apply
dev-mcluster-apply: envsubst
dev-mcluster-apply: envsubst ## Create dev managed cluster using 'config/dev/$(DEV_PROVIDER)-clusterdeployment.yaml'
@NAMESPACE=$(NAMESPACE) $(ENVSUBST) -no-unset -i config/dev/$(DEV_PROVIDER)-clusterdeployment.yaml | $(KUBECTL) apply -f -

.PHONY: dev-mcluster-delete
dev-mcluster-delete: envsubst
dev-mcluster-delete: envsubst ## Delete dev managed cluster using 'config/dev/$(DEV_PROVIDER)-clusterdeployment.yaml'
@NAMESPACE=$(NAMESPACE) $(ENVSUBST) -no-unset -i config/dev/$(DEV_PROVIDER)-clusterdeployment.yaml | $(KUBECTL) delete -f -

.PHONY: dev-creds-apply
dev-creds-apply: dev-$(DEV_PROVIDER)-creds
dev-creds-apply: dev-$(DEV_PROVIDER)-creds ## Create credentials resources for $DEV_PROVIDER

.PHONY: dev-aws-nuke
dev-aws-nuke: envsubst awscli yq cloud-nuke ## Warning: Destructive! Nuke all AWS resources deployed by 'DEV_PROVIDER=aws dev-mcluster-apply'
Expand Down Expand Up @@ -431,6 +439,10 @@ CAPI_OPERATOR_VERSION ?= v$(shell $(YQ) -r '.dependencies.[] | select(.name == "
CAPI_OPERATOR_CRD_PREFIX ?= "operator.cluster.x-k8s.io_"
CAPI_OPERATOR_CRDS ?= capi-operator-crds

CLUSTER_API_VERSION ?= v1.9.3
CLUSTER_API_CRD_PREFIX ?= "cluster.x-k8s.io_"
CLUSTER_API_CRDS ?= cluster-api-crds

## Tool Binaries
KUBECTL ?= kubectl
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen-$(CONTROLLER_TOOLS_VERSION)
Expand Down Expand Up @@ -511,8 +523,15 @@ $(CAPI_OPERATOR_CRDS): | $(YQ) $(EXTERNAL_CRD_DIR)
curl -s --fail https://raw.githubusercontent.com/kubernetes-sigs/cluster-api-operator/$(CAPI_OPERATOR_VERSION)/config/crd/bases/$(CAPI_OPERATOR_CRD_PREFIX)${name}.yaml \
> $(EXTERNAL_CRD_DIR)/$(CAPI_OPERATOR_CRD_PREFIX)${name}-$(CAPI_OPERATOR_VERSION).yaml;)

$(CLUSTER_API_CRDS): | $(YQ) $(EXTERNAL_CRD_DIR)
rm -f $(EXTERNAL_CRD_DIR)/$(CLUSTER_API_CRD_PREFIX)*
@$(foreach name, \
clusters machinedeployments, \
curl -s --fail https://raw.githubusercontent.com/kubernetes-sigs/cluster-api/$(CLUSTER_API_VERSION)/config/crd/bases/$(CLUSTER_API_CRD_PREFIX)${name}.yaml \
> $(EXTERNAL_CRD_DIR)/$(CLUSTER_API_CRD_PREFIX)${name}-$(CLUSTER_API_VERSION).yaml;)

.PHONY: external-crd
external-crd: $(FLUX_HELM_CRD) $(FLUX_SOURCE_CHART_CRD) $(FLUX_SOURCE_REPO_CRD) $(SVELTOS_CRD) $(CAPI_OPERATOR_CRDS)
external-crd: $(FLUX_HELM_CRD) $(FLUX_SOURCE_CHART_CRD) $(FLUX_SOURCE_REPO_CRD) $(SVELTOS_CRD) $(CAPI_OPERATOR_CRDS) $(CLUSTER_API_CRDS)

.PHONY: kind
kind: $(KIND) ## Download kind locally if necessary.
Expand Down
26 changes: 13 additions & 13 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ domain: hmc.mirantis.com
layout:
- go.kubebuilder.io/v4
projectName: hmc
repo: github.com/Mirantis/hmc
repo: github.com/K0rdent/kcm
resources:
- api:
crdVersion: v1
Expand All @@ -15,7 +15,7 @@ resources:
domain: hmc.mirantis.com
group: hmc.mirantis.com
kind: ClusterDeployment
path: github.com/Mirantis/hmc/api/v1alpha1
path: github.com/K0rdent/kcm/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -24,14 +24,14 @@ resources:
domain: hmc.mirantis.com
group: hmc.mirantis.com
kind: Management
path: github.com/Mirantis/hmc/api/v1alpha1
path: github.com/K0rdent/kcm/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
domain: hmc.mirantis.com
group: hmc.mirantis.com
kind: Release
path: github.com/Mirantis/hmc/api/v1alpha1
path: github.com/K0rdent/kcm/api/v1alpha1
version: v1alpha1
webhooks:
validation: true
Expand All @@ -43,7 +43,7 @@ resources:
domain: hmc.mirantis.com
group: hmc.mirantis.com
kind: ClusterTemplate
path: github.com/Mirantis/hmc/api/v1alpha1
path: github.com/K0rdent/kcm/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -52,7 +52,7 @@ resources:
domain: hmc.mirantis.com
group: hmc.mirantis.com
kind: ProviderTemplate
path: github.com/Mirantis/hmc/api/v1alpha1
path: github.com/K0rdent/kcm/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -61,7 +61,7 @@ resources:
domain: hmc.mirantis.com
group: hmc.mirantis.com
kind: ServiceTemplate
path: github.com/Mirantis/hmc/api/v1alpha1
path: github.com/K0rdent/kcm/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -70,22 +70,22 @@ resources:
domain: hmc.mirantis.com
group: hmc.mirantis.com
kind: AccessManagement
path: github.com/Mirantis/hmc/api/v1alpha1
path: github.com/K0rdent/kcm/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
domain: hmc.mirantis.com
group: hmc.mirantis.com
kind: ClusterTemplateChain
path: github.com/Mirantis/hmc/api/v1alpha1
path: github.com/K0rdent/kcm/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
domain: hmc.mirantis.com
group: hmc.mirantis.com
kind: ServiceTemplateChain
path: github.com/Mirantis/hmc/api/v1alpha1
path: github.com/K0rdent/kcm/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -94,15 +94,15 @@ resources:
domain: hmc.mirantis.com
group: hmc.mirantis.com
kind: Credential
path: github.com/Mirantis/hmc/api/v1alpha1
path: github.com/K0rdent/kcm/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
controller: true
domain: hmc.mirantis.com
group: hmc.mirantis.com
kind: MultiClusterService
path: github.com/Mirantis/hmc/api/v1alpha1
path: github.com/K0rdent/kcm/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -111,6 +111,6 @@ resources:
domain: hmc.mirantis.com
group: hmc.mirantis.com
kind: Backup
path: github.com/Mirantis/hmc/api/v1alpha1
path: github.com/K0rdent/kcm/api/v1alpha1
version: v1alpha1
version: "3"
Loading

0 comments on commit ffcdb58

Please sign in to comment.