Skip to content

MGMT-18418: Use Image Service HTTP IP for live iso URL - #51

Merged
openshift-merge-bot[bot] merged 1 commit into
masterfrom
fix-for-tls
Aug 9, 2024
Merged

openshift-merge-bot[bot] merged 1 commit into
masterfrom
fix-for-tls

Conversation

@CrystalChun

Copy link
Copy Markdown
Collaborator

Ironic is unable to pull using assisted-service's CA certificate from changes in openshift/assisted-service#6564 https://issues.redhat.com/browse/MGMT-18418

Adds the option to use the internal IP of the service as the URL to provision the BMH so Ironic can pull the image without TLS verification.

@CrystalChun
CrystalChun requested a review from rccrdpccl July 19, 2024 23:38
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 19, 2024
@openshift-ci-robot

openshift-ci-robot commented Jul 19, 2024 •

Copy link
Copy Markdown

@CrystalChun: This pull request references MGMT-18418 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.17.0" version, but no target version was set.

Details

In response to this:

Ironic is unable to pull using assisted-service's CA certificate from changes in openshift/assisted-service#6564 https://issues.redhat.com/browse/MGMT-18418

Adds the option to use the internal IP of the service as the URL to provision the BMH so Ironic can pull the image without TLS verification.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci

openshift-ci Bot commented Jul 19, 2024

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CrystalChun

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 19, 2024
@CrystalChun
CrystalChun requested a review from carbonin July 22, 2024 15:21
// UseInsecureImageURL when set to false means that we'll use the InfraEnv's iso download URL
// as is. When set to true, it'll find the assisted-image-service's internal IP as part of the
// download URL.
UseInsecureImageURL bool `envconfig:"USE_INSECURE_IMAGE_URL" default:"false"`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "Internal" instead of "Insecure"?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds much better, thanks!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified!

Comment on lines +122 to +128
_, remainderURL, found := strings.Cut(originalURL, "byapikey") //TODO: will the URL always have this?
if !found {
return "", fmt.Errorf("failed to parse InfraEnv Download URL %s", originalURL)
}

//TODO: better way to build this string
downloadURL := "http://" + svc.Spec.ClusterIP + ":" + strconv.Itoa(int(svc.Spec.Ports[0].Port)) + "/byapikey" + remainderURL

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should do all of this with the standard library net/url

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified to use the std lib net/url package!

Comment thread bootstrap/internal/controller/infraenv_controller.go
Comment thread bootstrap/internal/controller/infraenv_controller.go Outdated
Comment thread bootstrap/internal/controller/infraenv_controller.go Outdated
@CrystalChun
CrystalChun force-pushed the fix-for-tls branch 2 times, most recently from 8bde368 to 96ac3b7 Compare July 22, 2024 23:51
@openshift-ci openshift-ci Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 22, 2024
Comment thread bootstrap/internal/controller/infraenv_controller_test.go Outdated
Comment thread bootstrap/config/manager/manager.yaml Outdated
@CrystalChun

Copy link
Copy Markdown
Collaborator Author

/retest

@carbonin carbonin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jianzzha can you put a review here? I want to make sure whatever we're building will work for how you want to deploy this.

- op: replace
path: "/spec/template/spec/containers/0/env/0"
value:
name: USE_INTERNAL_IMAGE_URL

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this was meant to allow someone deploying this to change the namespace for assisted. How does this do that?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stanza replaces the first environment variable listed in the base deployment yaml with the value specified here.

So the result of $ kustomize build bootstrap/config/manager/overlays/ocp
is this:

...
apiVersion: apps/v1
kind: Deployment
metadata:
...
  name: controller-manager
  namespace: system
spec:
  replicas: 1
  selector:
    matchLabels:
      control-plane: controller-manager
  template:
    metadata:
      annotations:
        kubectl.kubernetes.io/default-container: manager
      labels:
        control-plane: controller-manager
    spec:
      containers:
      - args:
        - --leader-elect
        command:
        - /manager
        env:
        - name: USE_INTERNAL_IMAGE_URL
          value: "false"
        - name: IMAGE_SERVICE_NAME
          value: assisted-image-service
        - name: IMAGE_SERVICE_NAMESPACE
          value: assisted-installer
        image: quay.io/edge-infrastructure/openshift-capi-agent-bootstrap:latest
        imagePullPolicy: Always
        livenessProbe:
...

Whereas just doing $ kustomize build bootstrap/config/manager/base
produces this:

...
apiVersion: apps/v1
kind: Deployment
metadata:
...
  name: controller-manager
  namespace: system
spec:
  replicas: 1
  selector:
    matchLabels:
      control-plane: controller-manager
  template:
    metadata:
      annotations:
        kubectl.kubernetes.io/default-container: manager
      labels:
        control-plane: controller-manager
    spec:
      containers:
      - args:
        - --leader-elect
        command:
        - /manager
        env:
        - name: USE_INTERNAL_IMAGE_URL
          value: "true"
        - name: IMAGE_SERVICE_NAME
          value: assisted-image-service
        - name: IMAGE_SERVICE_NAMESPACE
          value: assisted-installer
        image: quay.io/edge-infrastructure/openshift-capi-agent-bootstrap:latest
        imagePullPolicy: Always
        livenessProbe:
...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the purpose of the sylva integration, the released manifests are used. For example if release 0.1.5 will have this fix, it's the github.com/openshift-assisted/cluster-api-agent/releases/download/v0.1.5/{bootstrap-components.yaml,controlplane-components.yaml} will be used by Sylva. Since bootstrap-components.yaml is already updated, so I think we are good. We can always overwrite USE_INTERNAL_IMAGE_URL from a sylva unit via kustomization.

@CrystalChun This base/ and overlays/ocp/ folder are meant for internal use only, right? maybe they can be re-organized for some e2e CI test and used to deploy all manifests required for the CAPI provider to emulate how an end user will deploy the manifests on a k8s or OCP cluster. But that's outside of the scope of this PR and we can discuss that later.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the intention of kustomize folder is for users who has cloned the source repo to be able to use kubectl apply -k to deploy the capi pods and resources in one step. The root level README.md does mention kubectl apply -k config/samples/. So I guess the purpose of the base/ and overlays/ folder here will be eventually used for that purpose? @CrystalChun @rccrdpccl

image: controller:latest
imagePullPolicy: Always
name: manager
env:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be easier if we have the base layer without these envs, and just add them in the overlays? This way if we add other env vars the order would not matter.
Also, we should probably disable this behaviour by default and assume public addresses. If that's not the case the user should know and configure the provider accordingly (I know the main use case is with this feature enabled, but I feel we should enable it when we declare what address we have, as by default we would need to fail the controller if it's enabled but not internal namespace/service it's defined)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless what default value to choose, the usage of the env var needs to be documented in the README.md.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did initially try that (no env vars in the base and add them in overlay) but kustomize acted weird with it :/ I might've been patching it incorrectly though

// ImageServiceName is the Service CR name for the assisted-image-service
ImageServiceName string `envconfig:"IMAGE_SERVICE_NAME" default:"assisted-image-service"`
// ImageServiceNamespace is the namespace that the Service CR for the assisted-image-service is in
ImageServiceNamespace string `envconfig:"IMAGE_SERVICE_NAMESPACE" default:"assisted-installer"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this have a default from within the code? Normally we deploy this way, but can we really assume it from here? Wouldn't it be safer to force the use specify this?

@carbonin carbonin Jul 31, 2024 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the reason I asked @jianzzha to review.

I don't know what we will "normally" be doing.
When assisted is deployed through MCE it won't be in the assisted-installer namespace, but when we deploy it for dev, it is. I'm also not sure what namespace whatever MCE distribution we use for sylva will use. I don't know what to consider "normal" in this case.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sylva is referencing https://github.com/openshift/assisted-service/tree/master/config/default kustomize folder at this moment, so 'assisted-installer' namespace is set by that kustomize.

I'm assuming that MCE can kustomize the IMAGE_SERVICE_NAMESPACE if it needs to?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming that MCE can kustomize the IMAGE_SERVICE_NAMESPACE if it needs to?

This is what I'm trying to ensure. MCE does not use kustomize when deploying assisted. I assume it also won't use kustomize when deploying this CAPI provider (if it is even going to be responsible for that). MCE pulls the files from the rendered operator bundle and applies those.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the open question (for me at least) is still if MCE is going to deploy the CAPI providers or if they're being installed through some other means.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggested looking in the same namespace as a more sensible default than hardcoding assisted-installer.

I think we should still expose the env var as overrideable, but it was my understanding that we didn't have a good way to do that from kustomize without hardcoding other namespaces.

As for where these components are running we only have three cases:

  1. Everything installed from MCE -> everything runs in the same namespace
  2. Assisted installed from MCE, CAPI provider installed by user -> doc to run CAPI provider in assisted namespace
  3. User installs everything -> doc to run everything in the same namespace.

From what I could tell from the discussion around kustomize overrides for the namespace this seems more reliable.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see and agree that running everything in the same namespace might be more sensible than hardcoding assisted's namespace. What about the following:

  • Default to USE_INTERNAL_IMAGE_URL to false: this will use public route, where all of this is a non-issue and it would be the desired behaviour
  • Default IMAGE_SERVICE_NAMESPACE to empty: when empty it will mean same namespace (if override is turned on), however it can be overridden if need be.

In Sylva's "upstream" case, we'd only need to add one env var through kustomization (USE_INTERNAL_IMAGE_URL=true) and deploy in the same namespace.
In MCE case, everything would be deployed in the same namespace, but no overrides needed as we'd go through the advertised public address.

Basically my point is that the "workaround" (USE_INTERNAL_IMAGE_URL) should not be default behaviour. Would you agree?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In MCE case, everything would be deployed in the same namespace, but no overrides needed

You're still assuming whenever we run with MCE we're going to be in OCP and I'm not sure yet that this will always be true.
But that said, I beleive MCE's installer can set env vars when it deploys operators so we'd have to get them to set this in the OCP/kube case no matter what we choose so I don't think it's an issue.

Plus we're still a bit away from having MCE install this provider so we can probably deal with this when it's actually an issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be easier to just remove any "workaround" kustomization rather than having to change the upstream manifest, when/if we'll finally release that?
I feel we are making a workaround the default behaviour making some assumptions (what namespace we run what component) on the way. Shouldn't we allow the user to have this workaround and make the assumptions/decisions themselves?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a discussion offline, the decision was to remove the default value for the image service namespace. If provided we will use it to look up the service, if not we will look for the service in the namespace the provider is running in.

We will also default USE_INTERNAL_IMAGE_URL to false and the user will need to change that if they want/need to.

@CrystalChun
CrystalChun force-pushed the fix-for-tls branch 2 times, most recently from 151b466 to 1dc3451 Compare August 1, 2024 20:44
@CrystalChun
CrystalChun force-pushed the fix-for-tls branch 3 times, most recently from 747f184 to e040414 Compare August 5, 2024 19:20
// ImageServiceName is the Service CR name for the assisted-image-service
ImageServiceName string `envconfig:"IMAGE_SERVICE_NAME" default:"assisted-image-service"`
// ImageServiceNamespace is the namespace that the Service CR for the assisted-image-service is in
ImageServiceNamespace string `envconfig:"IMAGE_SERVICE_NAMESPACE" default:""`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super minor but we probably don't need the default at all here, right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yep good point! Removing it

@carbonin

carbonin commented Aug 5, 2024

Copy link
Copy Markdown
Collaborator

Looks good to me. I'll let @rccrdpccl give it the final lgtm though

@rccrdpccl

Copy link
Copy Markdown
Contributor

Could we please add some documentation about how would we use this feature and why?

@CrystalChun

Copy link
Copy Markdown
Collaborator Author

Could we please add some documentation about how would we use this feature and why?

Sorry missed it originally, just added it!

@CrystalChun
CrystalChun force-pushed the fix-for-tls branch 2 times, most recently from 1a37c0e to 3aa3d8d Compare August 6, 2024 19:11
Comment thread docs/deploy.md Outdated
Comment thread docs/deploy.md Outdated
The following services are required on your cluster before installing this provider.

1. Install [Assisted-Service operator](https://github.com/openshift/assisted-service/blob/master/docs/dev/operator-on-kind.md)
2. Install [CAPI](https://cluster-api.sigs.k8s.io/user/quick-start.html)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have some instructions in the readme about installing the providers, can we integrate those docs with these new instructions?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, yes tried to do so but since we're suggesting a kustomize with a patch, these instructions/prerequisites mostly stayed the same 😅 do you know how to do it with clusterctl?

Also would you like assisted service as a prerequisite for the general deployment instructions? I was assuming we're targeting OCP so assisted service would already be deployed and need not be listed as a general prerequisite. Only listed if it's vanilla kube. Let me know your thoughts!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK we cannot do this with clusterctl, but I meant maybe we can have one section explaining how to install, with all the variants.

Comment thread docs/deploy.md Outdated
Comment thread docs/deploy.md Outdated
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 8, 2024
@CrystalChun
CrystalChun force-pushed the fix-for-tls branch 2 times, most recently from adc1687 to e2be115 Compare August 9, 2024 00:18
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 9, 2024
Ironic is unable to pull using assisted-service's CA certificate
from changes in openshift/assisted-service#6564
https://issues.redhat.com/browse/MGMT-18418

Adds the option to use the internal IP of the service as the URL
to provision the BMH so Ironic can pull the image without
TLS verification.
@rccrdpccl

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 9, 2024
@openshift-merge-bot
openshift-merge-bot Bot merged commit ed569c2 into master Aug 9, 2024
@CrystalChun
CrystalChun deleted the fix-for-tls branch August 12, 2024 19:12
orenc1 pushed a commit to orenc1/cluster-api-provider-openshift-assisted that referenced this pull request Jun 9, 2026
…for-tls

MGMT-18418: Use Image Service HTTP IP for live iso URL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants