Skip to content

Commit

Permalink
OCPBUGS-22473: Added OLMCatalogPlacement option to the CLI
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Manuel Parrilla Madrid <jparrill@redhat.com>
  • Loading branch information
jparrill committed Nov 22, 2023
1 parent 27d0f8f commit 53da742
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/fixtures/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,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/hypershift/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 @@ -450,6 +453,26 @@ const (
GuestOLMCatalogPlacement OLMCatalogPlacement = "guest"
)

func (olm *OLMCatalogPlacement) String() string {
return string(*olm)
}

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 @@ -40,6 +40,7 @@ func NewCreateCommands() *cobra.Command {
NodeDrainTimeout: 0,
NodeUpgradeType: v1beta1.UpgradeTypeReplace,
Arch: "amd64",
OLMCatalogPlacement: v1beta1.ManagementOLMCatalogPlacement,
}
cmd := &cobra.Command{
Use: "cluster",
Expand Down Expand Up @@ -78,6 +79,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 @@ -78,6 +78,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 @@ -295,6 +296,7 @@ func createCommonFixture(ctx context.Context, opts *CreateOptions) (*apifixtures
NodeSelector: opts.NodeSelector,
UpgradeType: opts.NodeUpgradeType,
PausedUntil: opts.PausedUntil,
OLMCatalogPlacement: opts.OLMCatalogPlacement,
}, nil
}

Expand Down
12 changes: 12 additions & 0 deletions docs/content/how-to/disconnected/known-issues.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Known Issues

## OLM default catalog sources in ImagePullBackOff state

When you work in a disconnected environment the OLM catalog sources will be still pointing to their original source, so all of these container images will keep it in ImagePullBackOff state even if the OLMCatalogPlacement is set to `Management` or `Guest`. From this point you have some options ahead:

1. Disable those OLM default catalog sources and using the oc-mirror binary, mirror the desired images into your private registry, creating a new Custom Catalog Source.
2. Mirror all the Container Images from all the catalog sources and apply an ImageContentSourcePolicy to request those images from the private registry.

The most practical one is the first choice. To proceed with this option, you will need to follow [these instructions](https://docs.openshift.com/container-platform/4.14/installing/disconnected_install/installing-mirroring-disconnected.html). The process will make sure all the images get mirrored and also the ICSP will be generated properly.

Additionally when you're provisioning the HostedCluster you will need to add a flag to indicate that the OLMCatalogPlacement is set to `Guest` because if that's not set, you will not be able to disable them.
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 @@ -34,6 +34,7 @@ func NewCreateCommands() *cobra.Command {
Timeout: 0,
Wait: false,
PausedUntil: "",
OLMCatalogPlacement: v1beta1.ManagementOLMCatalogPlacement,
}

cmd := &cobra.Command{
Expand All @@ -60,6 +61,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

0 comments on commit 53da742

Please sign in to comment.