Skip to content

Commit

Permalink
WIP mods to bring up a PBC on a FCL API workload cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Wollesen committed Feb 16, 2023
1 parent 78cfefa commit 146eb63
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
11 changes: 11 additions & 0 deletions config/manifest/eksa-components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6005,6 +6005,17 @@ rules:
- delete
- update
- create
- apiGroups:
- packages.eks.amazonaws.com
resources:
- packagebundlecontrollers
verbs:
- create
- get
- list
- patch
- watch
- update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
Expand Down
5 changes: 4 additions & 1 deletion controllers/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,16 @@ func (r *ClusterReconciler) enablePackagesForWorkloadCluster(ctx context.Context

rm := registrymirror.FromCluster(cluster)
var options []curatedpackages.PackageControllerClientOpt
r.packageControllerClient.EnableCuratedPackagesFullLifecycle(ctx,
err = r.packageControllerClient.EnableCuratedPackagesFullLifecycle(ctx,
cluster.Name,
f.Name(),
image,
rm,
options...,
)
if err != nil {
return fmt.Errorf("package controller client error: %w", err)
}

return nil
}
Expand Down
3 changes: 2 additions & 1 deletion controllers/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/aws/eks-anywhere/pkg/crypto"
"github.com/aws/eks-anywhere/pkg/curatedpackages"
"github.com/aws/eks-anywhere/pkg/dependencies"
"github.com/aws/eks-anywhere/pkg/executables"
ciliumreconciler "github.com/aws/eks-anywhere/pkg/networking/cilium/reconciler"
cnireconciler "github.com/aws/eks-anywhere/pkg/networking/reconciler"
dockerreconciler "github.com/aws/eks-anywhere/pkg/providers/docker/reconciler"
Expand Down Expand Up @@ -393,7 +394,7 @@ func (f *Factory) withAWSIamConfigReconciler() *Factory {
}

func (f *Factory) withPackageControllerClient() *Factory {
f.dependencyFactory.WithHelm().WithKubectl()
f.dependencyFactory.WithHelm(executables.WithSkipCRDs()).WithKubectl()

f.buildSteps = append(f.buildSteps, func(ctx context.Context) error {
if f.packageControllerClient != nil {
Expand Down
6 changes: 6 additions & 0 deletions pkg/curatedpackages/packagecontrollerclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ func NewPackageControllerClientFullLifecycle(chartInstaller ChartInstaller, kube
}

func (pc *PackageControllerClient) EnableCuratedPackagesFullLifecycle(ctx context.Context, clusterName, kubeConfig string, chart *v1alpha1.Image, registryMirror *registrymirror.RegistryMirror, options ...PackageControllerClientOpt) error {
writer, err := filewriter.NewWriter(clusterName)
if err != nil {
return fmt.Errorf("creating new filewriter for helm values file writer: %w", err)
}
options = append(options, WithValuesFileWriter(writer))
newPC := NewPackageControllerClient(pc.chartInstaller, pc.kubectl, clusterName, kubeConfig, chart, registryMirror, options...)
pc = newPC // yuck!
return newPC.EnableCuratedPackages(ctx)
}

Expand Down
15 changes: 15 additions & 0 deletions pkg/executables/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type Helm struct {
registryMirror *registrymirror.RegistryMirror
env map[string]string
insecure bool
// skipCRDs passes the --skip-crds flag to the helm executable.
skipCRDs bool
}

type HelmOpt func(*Helm)
Expand All @@ -32,6 +34,16 @@ func WithRegistryMirror(mirror *registrymirror.RegistryMirror) HelmOpt {
}
}

// WithSkipCRDs configures helm to skip the creation of CRDs when installing a
// chart.
func WithSkipCRDs() HelmOpt {
return func(h *Helm) {
h.skipCRDs = true
}
}

// WithInsecure configures helm to skip validating TLS certificates when
// communicating with the Kubernetes API.
func WithInsecure() HelmOpt {
return func(h *Helm) {
h.insecure = true
Expand Down Expand Up @@ -127,6 +139,9 @@ func (h *Helm) InstallChartFromName(ctx context.Context, ociURI, kubeConfig, nam
func (h *Helm) InstallChart(ctx context.Context, chart, ociURI, version, kubeconfigFilePath, namespace, valueFilePath string, values []string) error {
valueArgs := GetHelmValueArgs(values)
params := []string{"install", chart, ociURI, "--version", version}
if h.skipCRDs {
params = append(params, "--skip-crds")
}
params = append(params, valueArgs...)
params = append(params, "--kubeconfig", kubeconfigFilePath)
if len(namespace) > 0 {
Expand Down

0 comments on commit 146eb63

Please sign in to comment.