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

Allow specifying custom storage class #4722

Merged
merged 5 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 1 addition & 3 deletions .github/actions/cmx-versions/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7656,9 +7656,7 @@ async function getClusterVersions() {
latest_minor_versions: true,
},
eks: {
// latest_version: true,
// TODO: re-enable latest_version once we have compatibility with 1.30
versions: new Set(["1.29"]),
latest_version: true,
instance_type: "m7g.large" // arm64
},
openshift: {
Expand Down
4 changes: 1 addition & 3 deletions .github/actions/cmx-versions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ async function getClusterVersions() {
latest_minor_versions: true,
},
eks: {
// latest_version: true,
// TODO: re-enable latest_version once we have compatibility with 1.30
versions: new Set(["1.29"]),
latest_version: true,
instance_type: "m7g.large" // arm64
},
openshift: {
Expand Down
1 change: 1 addition & 0 deletions .github/actions/kots-e2e/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ runs:
KOTS_DOCKERHUB_PASSWORD=${{ inputs.kots-dockerhub-password }} \
AIRGAP=${{ inputs.kots-airgap }} \
IS_OPENSHIFT=${{ inputs.k8s-distribution == 'openshift' && 'true' || 'false' }} \
IS_EKS=${{ inputs.k8s-distribution == 'eks' && 'true' || 'false' }} \
SKIP_TEARDOWN=1
shell: bash

Expand Down
2 changes: 2 additions & 0 deletions cmd/kots/cli/admin-console-generate-manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func AdminGenerateManifestsCmd() *cobra.Command {
options := upstreamtypes.WriteOptions{
Namespace: namespace,
SharedPassword: v.GetString("shared-password"),
StorageClassName: v.GetString("storage-class"),
HTTPProxyEnvValue: v.GetString("http-proxy"),
HTTPSProxyEnvValue: v.GetString("https-proxy"),
NoProxyEnvValue: v.GetString("no-proxy"),
Expand Down Expand Up @@ -98,6 +99,7 @@ func AdminGenerateManifestsCmd() *cobra.Command {
}

cmd.Flags().String("rootdir", ".", "root directory that will be used to write the yaml to")
cmd.Flags().String("storage-class", "", "sets the storage class to use for the KOTS Admin Console components (if unset, the default storage class will be used)")
cmd.Flags().String("http-proxy", "", "sets HTTP_PROXY environment variable in all KOTS Admin Console components")
cmd.Flags().String("https-proxy", "", "sets HTTPS_PROXY environment variable in all KOTS Admin Console components")
cmd.Flags().String("no-proxy", "", "sets NO_PROXY environment variable in all KOTS Admin Console components")
Expand Down
4 changes: 2 additions & 2 deletions cmd/kots/cli/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ func InstallCmd() *cobra.Command {
Airgap: isAirgap,
ProgressWriter: os.Stdout,
Timeout: time.Minute * 2,
StorageClassName: v.GetString("storage-class"),
HTTPProxyEnvValue: v.GetString("http-proxy"),
HTTPSProxyEnvValue: v.GetString("https-proxy"),
NoProxyEnvValue: v.GetString("no-proxy"),
Expand Down Expand Up @@ -504,6 +505,7 @@ func InstallCmd() *cobra.Command {
cmd.Flags().Int("port", 8800, "local port to listen on when port forwarding is enabled")
cmd.Flags().String("wait-duration", "2m", "timeout to be used while waiting for individual components to be ready. must be in Go duration format (eg: 10s, 2m)")
cmd.Flags().String("preflights-wait-duration", "15m", "timeout to be used while waiting for preflights to complete. must be in Go duration format (eg: 10s, 2m)")
cmd.Flags().String("storage-class", "", "sets the storage class to use for the KOTS Admin Console components (if unset, the default storage class will be used)")
cmd.Flags().String("http-proxy", "", "sets HTTP_PROXY environment variable in all KOTS Admin Console components")
cmd.Flags().String("https-proxy", "", "sets HTTPS_PROXY environment variable in all KOTS Admin Console components")
cmd.Flags().String("no-proxy", "", "sets NO_PROXY environment variable in all KOTS Admin Console components")
Expand All @@ -518,8 +520,6 @@ func InstallCmd() *cobra.Command {
cmd.Flags().String("app-version-label", "", "the application version label to install. if not specified, the latest version will be installed")
cmd.Flags().Bool("exclude-admin-console", false, "set to true to exclude the admin console and only install the application")

cmd.Flags().String("repo", "", "repo uri to use when installing a helm chart")

registryFlags(cmd.Flags())

// the following group of flags are experiemental and can be used to pull and push images during install time
Expand Down
2 changes: 2 additions & 0 deletions cmd/kots/cli/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func PullCmd() *cobra.Command {
Username: v.GetString("registry-username"),
Password: v.GetString("registry-password"),
},
StorageClassName: v.GetString("storage-class"),
HTTPProxyEnvValue: v.GetString("http-proxy"),
HTTPSProxyEnvValue: v.GetString("https-proxy"),
NoProxyEnvValue: v.GetString("no-proxy"),
Expand Down Expand Up @@ -127,6 +128,7 @@ func PullCmd() *cobra.Command {
cmd.Flags().Bool("exclude-kots-kinds", true, "set to true to exclude rendering kots custom objects to the base directory")
cmd.Flags().Bool("exclude-admin-console", false, "set to true to exclude the admin console (replicated apps only)")
cmd.Flags().String("shared-password", "", "shared password to use when deploying the admin console")
cmd.Flags().String("storage-class", "", "sets the storage class to use for the KOTS Admin Console components (if unset, the default storage class will be used)")
cmd.Flags().String("http-proxy", "", "sets HTTP_PROXY environment variable in all KOTS Admin Console components")
cmd.Flags().String("https-proxy", "", "sets HTTPS_PROXY environment variable in all KOTS Admin Console components")
cmd.Flags().String("no-proxy", "", "sets NO_PROXY environment variable in all KOTS Admin Console components")
Expand Down
2 changes: 2 additions & 0 deletions e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ test: KOTSADM_IMAGE_TAG ?= alpha
test: TESTIM_BRANCH ?= master
test: AIRGAP ?= 0
test: IS_OPENSHIFT ?= 0
test: IS_EKS ?= 0
test: SKIP_TEARDOWN ?= 0
ifneq ($(EXISTING_KUBECONFIG),)
test: EXISTING_KUBECONFIG_VOLUME_MOUNT := "-v=$(EXISTING_KUBECONFIG):$(EXISTING_KUBECONFIG)"
Expand All @@ -48,6 +49,7 @@ test:
--kotsadm-image-tag=$(KOTSADM_IMAGE_TAG) \
--airgap=$(AIRGAP) \
--is-openshift=$(IS_OPENSHIFT) \
--is-eks=$(IS_EKS) \
--kots-helm-chart-url=$(KOTS_HELM_CHART_URL) \
--kots-helm-chart-version=$(KOTS_HELM_CHART_VERSION) \
--kots-dockerhub-username=$(KOTS_DOCKERHUB_USERNAME) \
Expand Down
4 changes: 3 additions & 1 deletion e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var (
kotsadmImageTag string
airgap bool
isOpenShift bool
isEKS bool
kotsadmForwardPort string
kotsHelmChartURL string
kotsHelmChartVersion string
Expand All @@ -61,6 +62,7 @@ func init() {
flag.StringVar(&kotsadmImageTag, "kotsadm-image-tag", "alpha", "override the kotsadm images tag")
flag.BoolVar(&airgap, "airgap", false, "run install in airgapped mode")
flag.BoolVar(&isOpenShift, "is-openshift", false, "the cluster is an openshift cluster")
flag.BoolVar(&isEKS, "is-eks", false, "the cluster is an eks cluster")
flag.StringVar(&kotsadmForwardPort, "kotsadm-forward-port", "", "sets the port that the admin console will be exposed on instead of generating a random one")
flag.StringVar(&kotsHelmChartURL, "kots-helm-chart-url", "", "kots helm chart url")
flag.StringVar(&kotsHelmChartVersion, "kots-helm-chart-version", "", "kots helm chart version")
Expand Down Expand Up @@ -96,7 +98,7 @@ var _ = BeforeSuite(func() {

veleroCLI = velero.NewCLI(w.GetDir(), isOpenShift)

kotsInstaller = kots.NewInstaller(kotsadmImageRegistry, kotsadmImageNamespace, kotsadmImageTag, airgap, kotsDockerhubUsername, kotsDockerhubPassword)
kotsInstaller = kots.NewInstaller(kotsadmImageRegistry, kotsadmImageNamespace, kotsadmImageTag, airgap, kotsDockerhubUsername, kotsDockerhubPassword, isEKS)
})

var _ = AfterSuite(func() {
Expand Down
7 changes: 6 additions & 1 deletion e2e/kots/kots.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ type Installer struct {
airgap bool
dockerhubUsername string
dockerhubPassword string
isEKS bool
}

func NewInstaller(imageRegistry, imageNamespace, imageTag string, airgap bool, dockerhubUsername string, dockerhubPassword string) *Installer {
func NewInstaller(imageRegistry, imageNamespace, imageTag string, airgap bool, dockerhubUsername string, dockerhubPassword string, isEKS bool) *Installer {
return &Installer{
imageRegistry: imageRegistry,
imageNamespace: imageNamespace,
imageTag: imageTag,
airgap: airgap,
dockerhubUsername: dockerhubUsername,
dockerhubPassword: dockerhubPassword,
isEKS: isEKS,
}
}

Expand Down Expand Up @@ -100,6 +102,9 @@ func (i *Installer) install(kubeconfig string, test inventory.Test) (*gexec.Sess
fmt.Sprintf("--use-minimal-rbac=%t", test.UseMinimalRBAC),
fmt.Sprintf("--skip-compatibility-check=%t", test.SkipCompatibilityCheck),
}
if i.isEKS {
args = append(args, "--storage-class=gp2")
}

return util.RunCommand(exec.Command("kots", args...))
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/kotsadm/objects/kotsadm_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,11 @@ func KotsadmStatefulSet(deployOptions types.DeployOptions, size resource.Quantit
})
}

var storageClassName *string
if deployOptions.StorageClassName != "" {
storageClassName = &deployOptions.StorageClassName
}

statefulset := &appsv1.StatefulSet{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Expand Down Expand Up @@ -1165,6 +1170,7 @@ func KotsadmStatefulSet(deployOptions types.DeployOptions, size resource.Quantit
Labels: types.GetKotsadmLabels(),
},
Spec: corev1.PersistentVolumeClaimSpec{
StorageClassName: storageClassName,
AccessModes: []corev1.PersistentVolumeAccessMode{
corev1.ReadWriteOnce,
},
Expand Down
6 changes: 6 additions & 0 deletions pkg/kotsadm/objects/minio_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ func MinioStatefulset(deployOptions types.DeployOptions, size resource.Quantity)
},
}

var storageClassName *string
if deployOptions.StorageClassName != "" {
storageClassName = &deployOptions.StorageClassName
}

initContainers := []corev1.Container{}
if deployOptions.MigrateToMinioXl {
initContainers = append(initContainers, migrateToMinioXlInitContainers(deployOptions, resourceRequirements)...)
Expand Down Expand Up @@ -103,6 +108,7 @@ func MinioStatefulset(deployOptions types.DeployOptions, size resource.Quantity)
Labels: types.GetKotsadmLabels(),
},
Spec: corev1.PersistentVolumeClaimSpec{
StorageClassName: storageClassName,
AccessModes: []corev1.PersistentVolumeAccessMode{
corev1.ReadWriteOnce,
},
Expand Down
6 changes: 6 additions & 0 deletions pkg/kotsadm/objects/rqlite_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ func RqliteStatefulset(deployOptions types.DeployOptions, size resource.Quantity
memoryRequest, memoryLimit = "512Mi", "1Gi"
}

var storageClassName *string
if deployOptions.StorageClassName != "" {
storageClassName = &deployOptions.StorageClassName
}

statefulset := &appsv1.StatefulSet{
TypeMeta: metav1.TypeMeta{
APIVersion: "apps/v1",
Expand All @@ -70,6 +75,7 @@ func RqliteStatefulset(deployOptions types.DeployOptions, size resource.Quantity
Labels: types.GetKotsadmLabels(),
},
Spec: corev1.PersistentVolumeClaimSpec{
StorageClassName: storageClassName,
AccessModes: []corev1.PersistentVolumeAccessMode{
corev1.ReadWriteOnce,
},
Expand Down
1 change: 1 addition & 0 deletions pkg/kotsadm/types/deployoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type DeployOptions struct {
CurrentMinioImage string
Timeout time.Duration
PreflightsTimeout time.Duration
StorageClassName string
HTTPProxyEnvValue string
HTTPSProxyEnvValue string
NoProxyEnvValue string
Expand Down
2 changes: 2 additions & 0 deletions pkg/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type PullOptions struct {
AppSequence int64
AppVersionLabel string
IsGitOps bool
StorageClassName string
HTTPProxyEnvValue string
HTTPSProxyEnvValue string
NoProxyEnvValue string
Expand Down Expand Up @@ -291,6 +292,7 @@ func Pull(upstreamURI string, pullOptions PullOptions) (string, error) {
IncludeAdminConsole: includeAdminConsole,
SharedPassword: pullOptions.SharedPassword,
EncryptConfig: encryptConfig,
StorageClassName: pullOptions.StorageClassName,
HTTPProxyEnvValue: pullOptions.HTTPProxyEnvValue,
HTTPSProxyEnvValue: pullOptions.HTTPSProxyEnvValue,
NoProxyEnvValue: pullOptions.NoProxyEnvValue,
Expand Down
4 changes: 4 additions & 0 deletions pkg/upstream/admin-console.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type UpstreamSettings struct {
JWT string
RqlitePassword string
APIEncryptionKey string
StorageClassName string
HTTPProxyEnvValue string
HTTPSProxyEnvValue string
NoProxyEnvValue string
Expand All @@ -50,6 +51,7 @@ func GenerateAdminConsoleFiles(renderDir string, options types.WriteOptions) ([]
Namespace: options.Namespace,
SharedPassword: options.SharedPassword,
AutoCreateClusterToken: uuid.New().String(),
StorageClassName: options.StorageClassName,
HTTPProxyEnvValue: options.HTTPProxyEnvValue,
HTTPSProxyEnvValue: options.HTTPSProxyEnvValue,
NoProxyEnvValue: options.NoProxyEnvValue,
Expand All @@ -73,6 +75,7 @@ func GenerateAdminConsoleFiles(renderDir string, options types.WriteOptions) ([]
settings := &UpstreamSettings{
Namespace: options.Namespace,
AutoCreateClusterToken: uuid.New().String(),
StorageClassName: options.StorageClassName,
IsOpenShift: options.IsOpenShift,
IsGKEAutopilot: options.IsGKEAutopilot,
IncludeMinio: options.IncludeMinio,
Expand Down Expand Up @@ -175,6 +178,7 @@ func generateNewAdminConsoleFiles(settings *UpstreamSettings) ([]types.UpstreamF
RqlitePassword: settings.RqlitePassword,
APIEncryptionKey: settings.APIEncryptionKey,
AutoCreateClusterToken: settings.AutoCreateClusterToken,
StorageClassName: settings.StorageClassName,
HTTPProxyEnvValue: settings.HTTPProxyEnvValue,
HTTPSProxyEnvValue: settings.HTTPSProxyEnvValue,
NoProxyEnvValue: settings.NoProxyEnvValue,
Expand Down
1 change: 1 addition & 0 deletions pkg/upstream/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type WriteOptions struct {
IncludeMinio bool
MigrateToMinioXl bool
CurrentMinioImage string
StorageClassName string
HTTPProxyEnvValue string
HTTPSProxyEnvValue string
NoProxyEnvValue string
Expand Down
Loading