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

[GENERAL QUESTION] Is there a clusterversion equivalent for MicroShift? #731

Closed
piyat opened this issue Jun 14, 2022 · 9 comments
Closed

Comments

@piyat
Copy link

piyat commented Jun 14, 2022

I'm using MicroShift to test an Operator (in CI) which usually runs in OpenShift. I want to determine whether I'm running in MicroShift or OpenShift and skip some code if I'm in MicroShift. I don't think MicroShift has the config.openshift.io API.

Is there an equivalent to oc get clusterversion available to me in MicroShift, or any API I can use to tell my operator "you are in MicroShift".

Ideally I want this to be possible in-cluster (i.e. without the microshift cli).

How to reproduce it (as minimally and precisely as possible):

Attempt #1:

Run oc get clusterversion in an OpenShift cluster:
NAME VERSION AVAILABLE PROGRESSING SINCE STATUS
version 4.9.29 True False 25d Cluster version is 4.9.29

Run oc get clusterversion in MicroShift cluster:
error: the server doesn't have a resource type "clusterversion"

Attempt #2:

Run oc cluster-info

Attempt #3:

Run oc status

Attempt #4:

Run oc get consoles

Environment:

  • Microshift version (use microshift version):
    MicroShift Version: 4.8.0-0.microshift-2022-04-20-141053
    Base OKD Version: 4.8.0-0.okd-2021-10-10-030117

  • Hardware configuration:
    Running in Docker 1.13.1 on RHEL 7.9

  • OS (e.g: cat /etc/os-release):

cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)

  • Kernel (e.g. uname -a):
    Linux ip-10-64-58-162.eu-west-1.compute.internal 3.10.0-1160.24.1.el7.x86_64 Init #1 SMP Thu Mar 25 21:21:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Thanks!

@derekwaynecarr
Copy link
Member

could be a motivation to make this advertisable via Infrastructure CR.

@piyat
Copy link
Author

piyat commented Jun 17, 2022

Cheers for replying @derekwaynecarr

I don't seem to have that CR in my cluster. No hits foroc api-resources | grep -i infra.

Would it be feasible to publish the distribution, something like "clusterType: MicroShift" in the CRD?

As a workaround I'm distinguishing between MS + OCP by the presence of ACM related open-cluster-management-agent pods, this is not going to work for me long term though.

@dhellmann
Copy link
Contributor

@piyat which behaviors of MicroShift are different from OCP that lead to you needing to "skip some code"?

@piyat
Copy link
Author

piyat commented Jun 21, 2022

Hey @dhellmann - it's a similar thing to the above (some APIs are unavailable).

I'm unable to assert which specific cluster I'm in because I can't get dnses in my microshift cluster. When the Operator runs in OCP, I check the dns matches a field in the custom resource as a safety measure (to ensure the CR being reconciled was intended for the cluster it has been created in). In a CI environment, this check is superfluous so I want to skip it.

@dhellmann
Copy link
Contributor

The normal advice we give is not to look at the version of the platform, but look at the supported versions of APIs. So if you need a Foo CRD at a specific version level, look for that rather than ClusterVersion or the platform configuration APIs.

Is that possible in your case?

@piyat
Copy link
Author

piyat commented Jun 22, 2022

Just to clarify - as the ticket summary might be a bit misleading - I'm not actually trying to get the version, but instead the value of .spec.clusterID from the clusterversion resource as one method for asserting the cluster type. I'm not wedded to that method though, if there's better options.

I think your response relates to testing which version of (OCP) MicroShift I'm running, but the problem of distinguishing MicroShift vs OpenShift remains the same (unless I've misunderstood what you've said).

As the check depends on dnses, and I know that OCP clusters have this kind, I could test for the presence of it and if absent, make the assumption that I'm in a MicroShift cluster (though this falls down if I want to run on K8s).

It would be nice if there was a way to determine MicroShift or OpenShift or K8s by querying a cluster API.

@dhellmann
Copy link
Contributor

As the check depends on dnses, and I know that OCP clusters have this kind, I could test for the presence of it and if absent, make the assumption that I'm in a MicroShift cluster (though this falls down if I want to run on K8s).

It would be nice if there was a way to determine MicroShift or OpenShift or K8s by querying a cluster API.

Like I said, we don't recommend making decisions in code based on the cluster type. It's more reliable to test for the actual feature you need, because then if the APIs supported in MicroShift or OCP change, your code will still work reliably.

What feature of OCP do you use that isn't in MicroShift? What logic would be in the different branches of the if or switch statement that you're trying to write based on figuring out what type of cluster the code sees?

@dhellmann
Copy link
Contributor

I think this is resolved by #180.

@dhellmann
Copy link
Contributor

See also https://github.com/openshift/microshift/blob/main/docs/debugging_tips.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants