Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple endpoints for cloudstack preflight check #2404

Closed
wants to merge 2 commits into from
Closed
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
40 changes: 26 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ ORGANIZE_BINARIES_TARGETS = $(addsuffix /eks-a-tools,$(addprefix $(BINARY_DEPS_D

EKS_A_PLATFORMS ?= linux-amd64 linux-arm64 darwin-arm64 darwin-amd64
EKS_A_CROSS_PLATFORMS := $(foreach platform,$(EKS_A_PLATFORMS),eks-a-cross-platform-$(platform))
E2E_CROSS_PLATFORMS := $(foreach platform,$(EKS_A_PLATFORMS),e2e-cross-platform-$(platform))
EKS_A_RELEASE_CROSS_PLATFORMS := $(foreach platform,$(EKS_A_PLATFORMS),eks-a-release-cross-platform-$(platform))

DOCKER_E2E_TEST := TestDockerKubernetes121SimpleFlow
Expand All @@ -137,12 +138,12 @@ build: eks-a eks-a-tool unit-test ## Generate binaries and run unit tests
release: eks-a-release unit-test ## Generate release binary and run unit tests

.PHONY: eks-a-binary
eks-a-binary: ALL_LINKER_FLAGS := $(LINKER_FLAGS) -X github.com/aws/eks-anywhere/pkg/version.gitVersion=$(GIT_VERSION) -X github.com/aws/eks-anywhere/pkg/cluster.releasesManifestURL=$(RELEASE_MANIFEST_URL) -X github.com/aws/eks-anywhere/pkg/manifests/releases.manifestURL=$(RELEASE_MANIFEST_URL)
eks-a-binary: ALL_LINKER_FLAGS := $(LINKER_FLAGS) -X github.com/aws/eks-anywhere/pkg/version.gitVersion=$(GIT_VERSION) -X github.com/aws/eks-anywhere/pkg/cluster.releasesManifestURL=$(RELEASE_MANIFEST_URL) -X github.com/aws/eks-anywhere/pkg/manifests/releases.manifestURL=$(RELEASE_MANIFEST_URL) -s -w -buildid='' -extldflags -static
eks-a-binary: LINKER_FLAGS_ARG := -ldflags "$(ALL_LINKER_FLAGS)"
eks-a-binary: BUILD_TAGS_ARG := -tags "$(BUILD_TAGS)"
eks-a-binary: OUTPUT_FILE ?= bin/eksctl-anywhere
eks-a-binary:
GOOS=$(GO_OS) GOARCH=$(GO_ARCH) $(GO) build $(BUILD_TAGS_ARG) $(LINKER_FLAGS_ARG) $(BUILD_FLAGS) -o $(OUTPUT_FILE) github.com/aws/eks-anywhere/cmd/eksctl-anywhere
CGO_ENABLED=0 GOOS=$(GO_OS) GOARCH=$(GO_ARCH) $(GO) build $(BUILD_TAGS_ARG) $(LINKER_FLAGS_ARG) $(BUILD_FLAGS) -o $(OUTPUT_FILE) github.com/aws/eks-anywhere/cmd/eksctl-anywhere

.PHONY: eks-a-embed-config
eks-a-embed-config: ## Build a dev release version of eks-a with embed cluster spec config
Expand Down Expand Up @@ -415,7 +416,7 @@ mocks: ## Generate mocks
${GOPATH}/bin/mockgen -destination=pkg/cluster/mocks/client.go -package=mocks "github.com/aws/eks-anywhere/pkg/cluster" ClusterClient
${GOPATH}/bin/mockgen -destination=pkg/git/providers/github/mocks/github.go -package=mocks "github.com/aws/eks-anywhere/pkg/git/providers/github" GithubClient
${GOPATH}/bin/mockgen -destination=pkg/git/mocks/git.go -package=mocks "github.com/aws/eks-anywhere/pkg/git" Client,ProviderClient
${GOPATH}/bin/mockgen -destination=pkg/workflows/interfaces/mocks/clients.go -package=mocks "github.com/aws/eks-anywhere/pkg/workflows/interfaces" Bootstrapper,ClusterManager,AddonManager,Validator,CAPIManager,EksdInstaller,EksdUpgrader
${GOPATH}/bin/mockgen -destination=pkg/workflows/interfaces/mocks/clients.go -package=mocks "github.com/aws/eks-anywhere/pkg/workflows/interfaces" Bootstrapper,ClusterManager,AddonManager,Validator,CAPIManager,EksdInstaller,EksdUpgrader,PackageInstaller
${GOPATH}/bin/mockgen -destination=pkg/git/gogithub/mocks/client.go -package=mocks "github.com/aws/eks-anywhere/pkg/git/gogithub" Client
${GOPATH}/bin/mockgen -destination=pkg/git/gitclient/mocks/client.go -package=mocks "github.com/aws/eks-anywhere/pkg/git/gitclient" GoGit
${GOPATH}/bin/mockgen -destination=pkg/validations/mocks/docker.go -package=mocks "github.com/aws/eks-anywhere/pkg/validations" DockerExecutable
Expand Down Expand Up @@ -465,19 +466,20 @@ verify-mocks: mocks ## Verify if mocks need to be updated
exit 1;\
fi

.PHONY: e2e-cross-platform
e2e-cross-platform: $(E2E_CROSS_PLATFORMS)

.PHONY: e2e-cross-platform-%
e2e-cross-platform-%: ## Generate binaries for Linux and MacOS
e2e-cross-platform-%: GO_OS = $(firstword $(subst -, ,$*))
e2e-cross-platform-%: GO_ARCH = $(lastword $(subst -, ,$*))
e2e-cross-platform-%:
$(MAKE) e2e-tests-binary E2E_TAGS=e2e GIT_VERSION=$(DEV_GIT_VERSION) GO_OS=$(GO_OS) GO_ARCH=$(GO_ARCH) E2E_OUTPUT_FILE=bin/$(GO_OS)/$(GO_ARCH)/e2e.test

.PHONY: e2e
e2e: eks-a-e2e integration-test-binary ## Build integration tests
$(MAKE) e2e-tests-binary E2E_TAGS=e2e

.PHONY: conformance
conformance:
$(MAKE) e2e-tests-binary E2E_TAGS=conformance_e2e
./bin/e2e.test -test.v -test.run 'TestVSphereKubernetes121ThreeWorkersConformanc.*'

.PHONY: conformance-tests
conformance-tests: eks-a-e2e integration-test-binary ## Build e2e conformance tests
$(MAKE) e2e-tests-binary E2E_TAGS=conformance_e2e

.PHONY: eks-a-e2e
eks-a-e2e:
if [ "$(CODEBUILD_CI)" = "true" ]; then \
Expand All @@ -496,12 +498,22 @@ eks-a-e2e:
fi

.PHONY: e2e-tests-binary
e2e-tests-binary: E2E_OUTPUT_FILE ?= bin/e2e.test
e2e-tests-binary:
$(GO) test ./test/e2e -c -o bin/e2e.test -tags "$(E2E_TAGS)" -ldflags "-X github.com/aws/eks-anywhere/pkg/version.gitVersion=$(DEV_GIT_VERSION) -X github.com/aws/eks-anywhere/pkg/cluster.releasesManifestURL=$(RELEASE_MANIFEST_URL) -X github.com/aws/eks-anywhere/pkg/manifests/releases.manifestURL=$(RELEASE_MANIFEST_URL)"
GOOS=$(GO_OS) GOARCH=$(GO_ARCH) $(GO) test ./test/e2e -c -o bin/e2e.test -tags "$(E2E_TAGS)" -ldflags "-X github.com/aws/eks-anywhere/pkg/version.gitVersion=$(DEV_GIT_VERSION) -X github.com/aws/eks-anywhere/pkg/cluster.releasesManifestURL=$(RELEASE_MANIFEST_URL) -X github.com/aws/eks-anywhere/pkg/manifests/releases.manifestURL=$(RELEASE_MANIFEST_URL)"

.PHONY: integration-test-binary
integration-test-binary:
$(GO) build -o bin/test github.com/aws/eks-anywhere/cmd/integration_test
GOOS=$(GO_OS) GOARCH=$(GO_ARCH) $(GO) build -o bin/test github.com/aws/eks-anywhere/cmd/integration_test

.PHONY: conformance
conformance:
$(MAKE) e2e-tests-binary E2E_TAGS=conformance_e2e
./bin/e2e.test -test.v -test.run 'TestVSphereKubernetes121ThreeWorkersConformanc.*'

.PHONY: conformance-tests
conformance-tests: eks-a-e2e integration-test-binary ## Build e2e conformance tests
$(MAKE) e2e-tests-binary E2E_TAGS=conformance_e2e

.PHONY: check-eksa-components-override
check-eksa-components-override:
Expand Down
3 changes: 1 addition & 2 deletions cmd/eksctl-anywhere/cmd/applypackages.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ var applyPackagesCommand = &cobra.Command{

func applyPackages(ctx context.Context) error {
kubeConfig := kubeconfig.FromEnvironment()
deps, err := curatedpackages.NewDependenciesForPackages(ctx, kubeConfig)
deps, err := NewDependenciesForPackages(ctx, WithMountPaths(kubeConfig))
if err != nil {
return fmt.Errorf("unable to initialize executables: %v", err)
}
packages := curatedpackages.NewPackageClient(
nil,
deps.Kubectl,
)

Expand Down
49 changes: 49 additions & 0 deletions cmd/eksctl-anywhere/cmd/common.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package cmd

import (
"context"

"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/dependencies"
"github.com/aws/eks-anywhere/pkg/kubeconfig"
"github.com/aws/eks-anywhere/pkg/version"
"github.com/aws/eks-anywhere/release/api/v1alpha1"
Expand All @@ -25,3 +28,49 @@ func getKubeconfigPath(clusterName, override string) string {
}
return override
}

func NewDependenciesForPackages(ctx context.Context, opts ...PackageOpt) (*dependencies.Dependencies, error) {
config := New(opts...)
return dependencies.NewFactory().
WithExecutableMountDirs(config.mountPaths...).
WithExecutableBuilder().
WithManifestReader().
WithKubectl().
WithHelm().
WithCuratedPackagesRegistry(config.registryName, config.kubeVersion, version.Get()).
Build(ctx)
}

type PackageOpt func(*PackageConfig)

type PackageConfig struct {
registryName string
kubeVersion string
mountPaths []string
}

func New(options ...PackageOpt) *PackageConfig {
pc := &PackageConfig{}
for _, o := range options {
o(pc)
}
return pc
}

func WithRegistryName(registryName string) func(*PackageConfig) {
return func(config *PackageConfig) {
config.registryName = registryName
}
}

func WithKubeVersion(kubeVersion string) func(*PackageConfig) {
return func(config *PackageConfig) {
config.kubeVersion = kubeVersion
}
}

func WithMountPaths(mountPaths ...string) func(*PackageConfig) {
return func(config *PackageConfig) {
config.mountPaths = mountPaths
}
}
10 changes: 5 additions & 5 deletions cmd/eksctl-anywhere/cmd/createcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func (cc *createClusterOptions) createCluster(cmd *cobra.Command, _ []string) er
WithFluxAddonClient(clusterSpec.Cluster, clusterSpec.FluxConfig, cliConfig).
WithWriter().
WithEksdInstaller().
WithPackageInstaller(clusterSpec, cc.installPackages).
Build(ctx)
if err != nil {
return err
Expand All @@ -165,17 +166,14 @@ func (cc *createClusterOptions) createCluster(cmd *cobra.Command, _ []string) er
return fmt.Errorf("provider snow is not supported in this release")
}

if !features.IsActive(features.CuratedPackagesSupport()) && cc.installPackages != "" {
return fmt.Errorf("curated packages installation is not supported in this release")
}

createCluster := workflows.NewCreate(
deps.Bootstrapper,
deps.Provider,
deps.ClusterManager,
deps.FluxAddonClient,
deps.Writer,
deps.EksdInstaller,
deps.PackageInstaller,
)

var cluster *types.Cluster
Expand Down Expand Up @@ -204,7 +202,8 @@ func (cc *createClusterOptions) createCluster(cmd *cobra.Command, _ []string) er
}
createValidations := createvalidations.New(validationOpts)

err = createCluster.Run(ctx, clusterSpec, createValidations, cc.forceClean, cc.installPackages)
err = createCluster.Run(ctx, clusterSpec, createValidations, cc.forceClean)

cleanup(deps, &err)
return err
}
Expand All @@ -215,6 +214,7 @@ func (cc *createClusterOptions) directoriesToMount(clusterSpec *cluster.Spec, cl
if fluxConfig != nil && fluxConfig.Spec.Git != nil {
dirs = append(dirs, filepath.Dir(cliConfig.GitPrivateKeyFile))
dirs = append(dirs, filepath.Dir(cliConfig.GitKnownHostsFile))
dirs = append(dirs, filepath.Dir(cc.installPackages))
}

if clusterSpec.Config.Cluster.Spec.DatacenterRef.Kind == v1alpha1.CloudStackDatacenterKind {
Expand Down
3 changes: 1 addition & 2 deletions cmd/eksctl-anywhere/cmd/createpackages.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ var createPackagesCommand = &cobra.Command{

func createPackages(ctx context.Context) error {
kubeConfig := kubeconfig.FromEnvironment()
deps, err := curatedpackages.NewDependenciesForPackages(ctx, kubeConfig)
deps, err := NewDependenciesForPackages(ctx, WithMountPaths(kubeConfig))
if err != nil {
return fmt.Errorf("unable to initialize executables: %v", err)
}
packages := curatedpackages.NewPackageClient(
nil,
deps.Kubectl,
)

Expand Down
3 changes: 1 addition & 2 deletions cmd/eksctl-anywhere/cmd/deletepackages.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ var deletePackageCommand = &cobra.Command{

func deleteResources(ctx context.Context, args []string) error {
kubeConfig := kubeconfig.FromEnvironment()
deps, err := curatedpackages.NewDependenciesForPackages(ctx, kubeConfig)
deps, err := NewDependenciesForPackages(ctx, WithMountPaths(kubeConfig))
if err != nil {
return fmt.Errorf("unable to initialize executables: %v", err)
}
packages := curatedpackages.NewPackageClient(
nil,
deps.Kubectl,
)

Expand Down
3 changes: 1 addition & 2 deletions cmd/eksctl-anywhere/cmd/describepackages.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ var describePackagesCommand = &cobra.Command{

func describeResources(ctx context.Context, args []string) error {
kubeConfig := kubeconfig.FromEnvironment()
deps, err := curatedpackages.NewDependenciesForPackages(ctx, kubeConfig)
deps, err := NewDependenciesForPackages(ctx, WithMountPaths(kubeConfig))
if err != nil {
return fmt.Errorf("unable to initialize executables: %v", err)
}
packages := curatedpackages.NewPackageClient(
nil,
deps.Kubectl,
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/eksctl-anywhere/cmd/generatehardware.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func init() {
flags := generateHardwareCmd.Flags()
flags.StringVarP(&hOpts.outputPath, "output", "o", "", "Path to output hardware YAML.")
flags.StringVarP(
&cc.hardwareCSVPath,
&hOpts.csvPath,
TinkerbellHardwareCSVFlagName,
TinkerbellHardwareCSVFlagAlias,
"",
Expand Down
17 changes: 4 additions & 13 deletions cmd/eksctl-anywhere/cmd/generatepackage.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/spf13/cobra"

"github.com/aws/eks-anywhere/pkg/config"
"github.com/aws/eks-anywhere/pkg/curatedpackages"
"github.com/aws/eks-anywhere/pkg/kubeconfig"
"github.com/aws/eks-anywhere/pkg/version"
Expand Down Expand Up @@ -51,19 +50,11 @@ func runGeneratePackages(cmd *cobra.Command, args []string) error {

func generatePackages(ctx context.Context, args []string) error {
kubeConfig := kubeconfig.FromEnvironment()
deps, err := curatedpackages.NewDependenciesForPackages(ctx, kubeConfig)
deps, err := NewDependenciesForPackages(ctx, WithRegistryName(gpOptions.registry), WithKubeVersion(gpOptions.kubeVersion), WithMountPaths(kubeConfig))
if err != nil {
return fmt.Errorf("unable to initialize executables: %v", err)
}
bm := curatedpackages.CreateBundleManager(gpOptions.kubeVersion)
username, password, err := config.ReadCredentials()
if err != nil && gpOptions.registry != "" {
return err
}
registry, err := curatedpackages.NewRegistry(deps, gpOptions.registry, gpOptions.kubeVersion, username, password)
if err != nil {
return err
}

b := curatedpackages.NewBundleReader(
kubeConfig,
Expand All @@ -72,7 +63,7 @@ func generatePackages(ctx context.Context, args []string) error {
deps.Kubectl,
bm,
version.Get(),
registry,
deps.BundleRegistry,
)

bundle, err := b.GetLatestBundle(ctx)
Expand All @@ -81,9 +72,9 @@ func generatePackages(ctx context.Context, args []string) error {
}

packageClient := curatedpackages.NewPackageClient(
bundle,
deps.Kubectl,
args...,
curatedpackages.WithBundle(bundle),
curatedpackages.WithCustomPackages(args),
)
packages, err := packageClient.GeneratePackages()
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions cmd/eksctl-anywhere/cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/spf13/viper"

"github.com/aws/eks-anywhere/pkg/constants"
"github.com/aws/eks-anywhere/pkg/curatedpackages"
"github.com/aws/eks-anywhere/pkg/features"
"github.com/aws/eks-anywhere/pkg/kubeconfig"
)
Expand Down Expand Up @@ -40,7 +39,7 @@ func preRunPackages(cmd *cobra.Command, args []string) error {
func getResources(ctx context.Context, resourceType string, output string, args []string) error {
kubeConfig := kubeconfig.FromEnvironment()

deps, err := curatedpackages.NewDependenciesForPackages(ctx, kubeConfig)
deps, err := NewDependenciesForPackages(ctx, WithMountPaths(kubeConfig))
if err != nil {
return fmt.Errorf("unable to initialize executables: %v", err)
}
Expand Down
4 changes: 1 addition & 3 deletions cmd/eksctl-anywhere/cmd/installpackagecontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func installPackageController(ctx context.Context) error {
return fmt.Errorf("the cluster config file provided is invalid: %v", err)
}

deps, err := curatedpackages.NewDependenciesForPackages(ctx)
deps, err := NewDependenciesForPackages(ctx, WithMountPaths(kubeConfig))
if err != nil {
return fmt.Errorf("unable to initialize executables: %v", err)
}
Expand All @@ -64,12 +64,10 @@ func installPackageController(ctx context.Context) error {
if err != nil {
return err
}

registryEndpoint := ""
if clusterSpec.Spec.RegistryMirrorConfiguration != nil {
registryEndpoint = clusterSpec.Spec.RegistryMirrorConfiguration.Endpoint
}

helmChart := versionBundle.PackageController.HelmChart
imageUrl := urls.ReplaceHost(helmChart.Image(), registryEndpoint)
ctrlClient := curatedpackages.NewPackageControllerClient(
Expand Down
Loading