-
Notifications
You must be signed in to change notification settings - Fork 152
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
WIP: Add support for OpenShift console on native Kubernetes #2996
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,8 @@ import ( | |
|
||
type ClusterInfo interface { | ||
Init(ctx context.Context, cl client.Client, logger logr.Logger) error | ||
IsOpenshift() bool | ||
IsNativeOpenshift() bool | ||
HasOpenshiftConsole() bool | ||
IsRunningLocally() bool | ||
GetDomain() string | ||
GetBaseDomain() string | ||
|
@@ -43,7 +44,8 @@ type ClusterInfo interface { | |
} | ||
|
||
type ClusterInfoImp struct { | ||
runningInOpenshift bool | ||
runningInNativeOpenshift bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't change the name of this field. We want to know if HCO is running in an openshift cluster or not, and this the old name is accurate. Also, I don't know what "native openshift" means. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I'll revert the name change 👍 |
||
runningWithOpenshiftConsole bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HCO and the openshift console are not actually related. so it's not like HCO is running with the console. What do you think about something like |
||
managedByOLM bool | ||
runningLocally bool | ||
controlPlaneHighlyAvailable bool | ||
|
@@ -78,15 +80,15 @@ func (c *ClusterInfoImp) Init(ctx context.Context, cl client.Client, logger logr | |
// We assume that this Operator is managed by OLM when this variable is present. | ||
_, c.managedByOLM = os.LookupEnv(OperatorConditionNameEnvVar) | ||
|
||
if c.runningInOpenshift { | ||
if c.runningInNativeOpenshift { | ||
err = c.initOpenshift(ctx, cl) | ||
} else { | ||
err = c.initKubernetes(cl) | ||
} | ||
if err != nil { | ||
return err | ||
} | ||
if c.runningInOpenshift && c.singlestackipv6 { | ||
if c.runningInNativeOpenshift && c.singlestackipv6 { | ||
metrics.SetHCOMetricSingleStackIPv6True() | ||
} | ||
|
||
|
@@ -179,8 +181,12 @@ func (c *ClusterInfoImp) IsManagedByOLM() bool { | |
return c.managedByOLM | ||
} | ||
|
||
func (c *ClusterInfoImp) IsOpenshift() bool { | ||
return c.runningInOpenshift | ||
func (c *ClusterInfoImp) IsNativeOpenshift() bool { | ||
return c.runningInNativeOpenshift | ||
} | ||
|
||
func (c *ClusterInfoImp) HasOpenshiftConsole() bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same: How do you feel about something like |
||
return c.runningInNativeOpenshift || c.runningWithOpenshiftConsole | ||
} | ||
|
||
func (c *ClusterInfoImp) IsConsolePluginImageProvided() bool { | ||
|
@@ -268,8 +274,9 @@ func isCRDExists(ctx context.Context, cl client.Client, crdName string) bool { | |
|
||
func init() { | ||
clusterInfo = &ClusterInfoImp{ | ||
runningLocally: IsRunModeLocal(), | ||
runningInOpenshift: false, | ||
runningLocally: IsRunModeLocal(), | ||
runningInNativeOpenshift: false, | ||
runningWithOpenshiftConsole: false, | ||
} | ||
} | ||
|
||
|
@@ -284,14 +291,16 @@ func (c *ClusterInfoImp) queryCluster(ctx context.Context, cl client.Client) err | |
var gdferr *discovery.ErrGroupDiscoveryFailed | ||
if meta.IsNoMatchError(err) || apierrors.IsNotFound(err) || errors.As(err, &gdferr) { | ||
// Not on OpenShift | ||
c.runningInOpenshift = false | ||
c.runningInNativeOpenshift = false | ||
c.logger.Info("Cluster type = kubernetes") | ||
c.runningWithOpenshiftConsole = isCRDExists(ctx, cl, OpenShiftConsolePluginCRDName) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that enough? Shouldn't we also check that the CR also exists? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
AaronDewes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else { | ||
c.logger.Error(err, "Failed to get ClusterVersion") | ||
return err | ||
} | ||
} else { | ||
c.runningInOpenshift = true | ||
c.runningInNativeOpenshift = true | ||
c.runningWithOpenshiftConsole = true | ||
c.logger.Info("Cluster type = openshift", "version", clusterVersion.Status.Desired.Version) | ||
c.domain, err = getClusterDomain(ctx, cl) | ||
if err != nil { | ||
|
@@ -318,7 +327,7 @@ func (c *ClusterInfoImp) GetTLSSecurityProfile(hcoTLSSecurityProfile *openshiftc | |
} | ||
|
||
func (c *ClusterInfoImp) RefreshAPIServerCR(ctx context.Context, cl client.Client) error { | ||
if c.IsOpenshift() { | ||
if c.IsNativeOpenshift() { | ||
instance := &openshiftconfigv1.APIServer{} | ||
|
||
key := client.ObjectKey{Namespace: UndefinedNamespace, Name: APIServerCRName} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about this whole logic. @tiraboschi - WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that the SSP operator (line 64) will work on vanially k8s just because the Openshift Console has been deployed there.