Skip to content

Commit

Permalink
Add Services (ServiceTemplates) to ManagedCluster to deploy on target…
Browse files Browse the repository at this point in the history
… cluster
  • Loading branch information
wahabmk committed Sep 23, 2024
1 parent 8f41aba commit 30c73ee
Show file tree
Hide file tree
Showing 22 changed files with 731 additions and 174 deletions.
47 changes: 46 additions & 1 deletion api/v1alpha1/managedcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const (
BlockingFinalizer = "hmc.mirantis.com/cleanup"
ManagedClusterFinalizer = "hmc.mirantis.com/managed-cluster"

FluxHelmChartNameKey = "helm.toolkit.fluxcd.io/name"
FluxHelmChartNameKey = "helm.toolkit.fluxcd.io/name"
FluxHelmChartNamespaceKey = "helm.toolkit.fluxcd.io/namespace"

HMCManagedLabelKey = "hmc.mirantis.com/managed"
HMCManagedLabelValue = "true"

Expand Down Expand Up @@ -60,6 +62,45 @@ const (
ProgressingReason string = "Progressing"
)

// ManagedClusterServiceSpec represents a Service within ManagedCluster
type ManagedClusterServiceSpec struct {
// Template is a reference to a Template object located in the same namespace.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
Template string `json:"template"`
// Install tells if this service should be installed.
// +kubebuilder:default:=true
Install bool `json:"install"`
// ReleaseName is the chart release.
// +kubebuilder:validation:MinLength=1
ReleaseName string `json:"releaseName"`
// ReleaseNamespace is the namespace the release will be installed in.
// It will default to ReleaseName if not provided.
// +optional
ReleaseNamespace string `json:"releaseNamespace"`
// CreateNamespace create the release namespace if not present.
// It will defaults to true if not provided.
// +kubebuilder:default:=true
// +optional
CreateNamespace bool `json:"createNamespace"`
// RegistryConfig to provide options to interact with registry.
// +optional
RegistryConfig *ManagedClusterServiceRegistryConfig `json:"registryConfig,omitempty"`
// Values is the helm values to be passed to the template.
// +optional
Values string `json:"values,omitempty"`
}

// ManagedClusterServiceRegistryConfig provides registry config per Service.
type ManagedClusterServiceRegistryConfig struct {
// PlainHTTP indicates to use insecure HTTP connections for the chart download.
// +optional
PlainHTTP bool `json:"plainHTTP"`
// Insecure indicates to skip tls certificate checks for the chart download.
// +optional
Insecure bool `json:"insecure"`
}

// ManagedClusterSpec defines the desired state of ManagedCluster
type ManagedClusterSpec struct {
// DryRun specifies whether the template should be applied after validation or only validated.
Expand All @@ -74,6 +115,10 @@ type ManagedClusterSpec struct {
// the template and DryRun will be enabled.
// +optional
Config *apiextensionsv1.JSON `json:"config,omitempty"`
// Services is a list of services created via ServiceTemplates
// that could be installed on the target cluster.
// +optional
Services []ManagedClusterServiceSpec `json:"services,omitempty"`
}

// ManagedClusterStatus defines the observed state of ManagedCluster
Expand Down
42 changes: 42 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

2 changes: 2 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"github.com/Mirantis/hmc/internal/telemetry"
"github.com/Mirantis/hmc/internal/utils"
hmcwebhook "github.com/Mirantis/hmc/internal/webhook"
sveltosv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1"
//+kubebuilder:scaffold:imports
)

Expand All @@ -54,6 +55,7 @@ func init() {
utilruntime.Must(hmcmirantiscomv1alpha1.AddToScheme(scheme))
utilruntime.Must(sourcev1.AddToScheme(scheme))
utilruntime.Must(hcv2.AddToScheme(scheme))
utilruntime.Must(sveltosv1beta1.AddToScheme(scheme))
//+kubebuilder:scaffold:scheme
}

Expand Down
17 changes: 17 additions & 0 deletions config/dev/aws-managedcluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,20 @@ spec:
workersNumber: 1
installBeachHeadServices: false
template: aws-standalone-cp
services:
- template: kyverno
install: true # defaults to true
releaseName: kyverno
releaseNamespace: kyverno # defaults to releaseName
createNamespace: true # defaults to true
registryConfig:
plainHTTP: true
- template: ingress-nginx
install: true
releaseName: ingress-nginx
releaseNamespace: ingress-nginx
createNamespace: false
values: |
fullnameOverride: ingress-nginx
registryConfig:
plainHTTP: true
68 changes: 36 additions & 32 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/Mirantis/hmc

go 1.22.0
go 1.22.7

require (
github.com/a8m/envsubst v1.4.2
Expand All @@ -15,43 +15,47 @@ require (
github.com/onsi/ginkgo/v2 v2.20.2
github.com/onsi/gomega v1.34.2
github.com/opencontainers/go-digest v1.0.1-0.20231025023718-d50d2fec9c98
github.com/projectsveltos/addon-controller v0.38.2
github.com/projectsveltos/libsveltos v0.38.2
github.com/segmentio/analytics-go v3.1.0+incompatible
gopkg.in/yaml.v3 v3.0.1
helm.sh/helm/v3 v3.16.1
k8s.io/api v0.31.1
k8s.io/apiextensions-apiserver v0.31.1
k8s.io/apimachinery v0.31.1
k8s.io/client-go v0.31.1
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
k8s.io/utils v0.0.0-20240902221715-702e33fdd3c3
sigs.k8s.io/cluster-api v1.8.3
sigs.k8s.io/controller-runtime v0.19.0
)

require (
dario.cat/mergo v1.0.1 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.3.0 // indirect
github.com/Masterminds/sprig/v3 v3.3.0 // indirect
github.com/Masterminds/squirrel v1.5.4 // indirect
github.com/Microsoft/hcsshim v0.11.4 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/containerd/containerd v1.7.12 // indirect
github.com/chai2010/gettext-go v1.0.3 // indirect
github.com/containerd/cgroups/v3 v3.0.3 // indirect
github.com/containerd/containerd v1.7.21 // indirect
github.com/containerd/errdefs v0.1.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/cyphar/filepath-securejoin v0.3.1 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/cyphar/filepath-securejoin v0.3.2 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/cli v25.0.1+incompatible // indirect
github.com/docker/cli v27.2.1+incompatible // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker v26.1.5+incompatible // indirect
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/docker v27.2.1+incompatible // indirect
github.com/docker/docker-credential-helpers v0.8.2 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-metrics v0.0.1 // indirect
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
Expand All @@ -77,14 +81,14 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 // indirect
github.com/google/pprof v0.0.0-20240910150728-a0b0bb1d4134 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/gosuri/uitable v0.0.4 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
Expand All @@ -104,12 +108,12 @@ require (
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/spdystream v0.4.0 // indirect
github.com/moby/spdystream v0.5.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand All @@ -119,11 +123,11 @@ require (
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.20.3 // indirect
github.com/prometheus/client_golang v1.20.4 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/common v0.59.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rivo/uniseg v0.4.2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rubenv/sql-migrate v1.7.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/segmentio/backo-go v1.1.0 // indirect
Expand All @@ -138,26 +142,26 @@ require (
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.starlark.net v0.0.0-20231121155337-90ade8b19d09 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel v1.30.0 // indirect
go.opentelemetry.io/otel/metric v1.30.0 // indirect
go.opentelemetry.io/otel/trace v1.30.0 // indirect
go.starlark.net v0.0.0-20240725214946-42030a7cedce // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.24.0 // indirect
golang.org/x/tools v0.25.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/grpc v1.66.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
Expand All @@ -166,9 +170,9 @@ require (
k8s.io/cli-runtime v0.31.1 // indirect
k8s.io/component-base v0.31.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f // indirect
k8s.io/kube-openapi v0.0.0-20240903163716-9e1beecbcb38 // indirect
k8s.io/kubectl v0.31.1 // indirect
oras.land/oras-go v1.2.5 // indirect
oras.land/oras-go v1.2.6 // indirect
sigs.k8s.io/gateway-api v1.1.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kustomize/api v0.17.3 // indirect
Expand Down
Loading

0 comments on commit 30c73ee

Please sign in to comment.