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

[release-4.14] OCPBUGS-23914: Added OLMCatalogPlacement option to the CLI #3229

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/fixtures/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type ExampleOptions struct {
ExternalDNSDomain string
Arch string
PausedUntil string
OLMCatalogPlacement hyperv1.OLMCatalogPlacement
AWS *ExampleAWSOptions
None *ExampleNoneOptions
Agent *ExampleAgentOptions
Expand Down Expand Up @@ -467,6 +468,10 @@ func (o ExampleOptions) Resources() *ExampleResources {
cluster.Spec.PausedUntil = &o.PausedUntil
}

if len(o.OLMCatalogPlacement) > 0 {
cluster.Spec.OLMCatalogPlacement = hyperv1.OLMCatalogPlacement(o.OLMCatalogPlacement)
}

if o.BaseDomainPrefix == "none" {
// set empty prefix explicitly
cluster.Spec.DNS.BaseDomainPrefix = pointer.String("")
Expand Down
23 changes: 23 additions & 0 deletions api/v1beta1/hostedcluster_types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package v1beta1

import (
"fmt"
"strings"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -455,6 +458,26 @@ const (
GuestOLMCatalogPlacement OLMCatalogPlacement = "guest"
)

func (olm *OLMCatalogPlacement) String() string {
return string(*olm)
jparrill marked this conversation as resolved.
Show resolved Hide resolved
}

func (olm *OLMCatalogPlacement) Set(s string) error {
switch strings.ToLower(s) {
case "guest":
*olm = GuestOLMCatalogPlacement
case "management":
*olm = ManagementOLMCatalogPlacement
default:
return fmt.Errorf("unknown OLMCatalogPlacement type used '%s'", s)
}
return nil
}

func (olm *OLMCatalogPlacement) Type() string {
return "OLMCatalogPlacement"
}

// ImageContentSource specifies image mirrors that can be used by cluster nodes
// to pull content. For cluster workloads, if a container image registry host of
// the pullspec matches Source then one of the Mirrors are substituted as hosts
Expand Down
2 changes: 2 additions & 0 deletions cmd/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func NewCreateCommands() *cobra.Command {
NodeDrainTimeout: 0,
NodeUpgradeType: v1beta1.UpgradeTypeReplace,
Arch: "amd64",
OLMCatalogPlacement: v1beta1.ManagementOLMCatalogPlacement,
}
cmd := &cobra.Command{
Use: "cluster",
Expand Down Expand Up @@ -81,6 +82,7 @@ func NewCreateCommands() *cobra.Command {
cmd.PersistentFlags().BoolVar(&opts.Wait, "wait", opts.Wait, "If the create command should block until the cluster is up. Requires at least one node.")
cmd.PersistentFlags().DurationVar(&opts.Timeout, "timeout", opts.Timeout, "If the --wait flag is set, set the optional timeout to limit the waiting duration. The format is duration; e.g. 30s or 1h30m45s; 0 means no timeout; default = 0")
cmd.PersistentFlags().Var(&opts.NodeUpgradeType, "node-upgrade-type", "The NodePool upgrade strategy for how nodes should behave when upgraded. Supported options: Replace, InPlace")
cmd.PersistentFlags().Var(&opts.OLMCatalogPlacement, "olmCatalogPlacement", "The OLM Catalog Placement for the HostedCluster. Supported options: Management, Guest")
cmd.PersistentFlags().StringVar(&opts.Arch, "arch", opts.Arch, "The default processor architecture for the NodePool (e.g. arm64, amd64)")
cmd.PersistentFlags().StringVar(&opts.PausedUntil, "pausedUntil", opts.PausedUntil, "If a date is provided in RFC3339 format, HostedCluster creation is paused until that date. If the boolean true is provided, HostedCluster creation is paused until the field is removed.")

Expand Down
2 changes: 2 additions & 0 deletions cmd/cluster/core/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type CreateOptions struct {
CredentialSecretName string
NodeUpgradeType hyperv1.UpgradeType
PausedUntil string
OLMCatalogPlacement hyperv1.OLMCatalogPlacement

// BeforeApply is called immediately before resources are applied to the
// server, giving the user an opportunity to inspect or mutate the resources.
Expand Down Expand Up @@ -304,6 +305,7 @@ func createCommonFixture(ctx context.Context, opts *CreateOptions) (*apifixtures
NodeSelector: opts.NodeSelector,
UpgradeType: opts.NodeUpgradeType,
PausedUntil: opts.PausedUntil,
OLMCatalogPlacement: opts.OLMCatalogPlacement,
}, nil
}

Expand Down
1 change: 1 addition & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ nav:
- how-to/disconnected/automatically-initialize-registry-overrides.md
- how-to/disconnected/image-content-sources.md
- how-to/disconnected/disconnected-workarounds.md
- how-to/disconnected/known-issues.md
- 'Kubevirt':
- how-to/kubevirt/create-kubevirt-cluster.md
- how-to/kubevirt/ingress-and-dns.md
Expand Down
2 changes: 2 additions & 0 deletions product-cli/cmd/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func NewCreateCommands() *cobra.Command {
Timeout: 0,
Wait: false,
PausedUntil: "",
OLMCatalogPlacement: v1beta1.ManagementOLMCatalogPlacement,
}

cmd := &cobra.Command{
Expand All @@ -62,6 +63,7 @@ func NewCreateCommands() *cobra.Command {
cmd.PersistentFlags().Int32Var(&opts.NodePoolReplicas, "node-pool-replicas", opts.NodePoolReplicas, "If set to 0 or greater, NodePools will be created with that many replicas. If set to less than 0, no NodePools will be created.")
cmd.PersistentFlags().StringToStringVar(&opts.NodeSelector, "node-selector", opts.NodeSelector, "A comma separated list of key=value pairs to use as the node selector for the Hosted Control Plane pods to stick to. (e.g. role=cp,disk=fast)")
cmd.PersistentFlags().Var(&opts.NodeUpgradeType, "node-upgrade-type", "The NodePool upgrade strategy for how nodes should behave when upgraded. Supported options: Replace, InPlace")
cmd.PersistentFlags().Var(&opts.OLMCatalogPlacement, "olmCatalogPlacement", "The OLM Catalog Placement for the HostedCluster. Supported options: Management, Guest")
cmd.PersistentFlags().StringVar(&opts.NetworkType, "network-type", opts.NetworkType, "Enum specifying the cluster SDN provider. Supports either Calico, OVNKubernetes, OpenShiftSDN or Other.")
cmd.PersistentFlags().StringVar(&opts.PullSecretFile, "pull-secret", opts.PullSecretFile, "Filepath to a pull secret.")
cmd.PersistentFlags().StringVar(&opts.ReleaseImage, "release-image", opts.ReleaseImage, "The OCP release image for the HostedCluster.")
Expand Down