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

🐛 Use API Server DNS Names by default when logging into VM Web Console #735

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

ammujumdar-bcom
Copy link
Contributor

@ammujumdar-bcom ammujumdar-bcom commented Oct 7, 2024

What does this PR do, and why is it needed?

In certain environments, a load balancer, and therefore a virtual IP, may not be present. In these cases, rather than relying on the virtual IP to log into the VM web console, we need to instead rely on an FQDN / DNS name to login.
This change plumbs the API Server DNS Names from the app platform CRD, and uses that by default to login to the VM Web Console. If no DNS Name is found, then we fall back to the previous method of using the virtual IP to login.

Testing Done:

Used an existing testbed - note that this setup has a load balancer already

Setup steps:

  1. Deployed a VM named my-vm on test-namespace
  2. On control plane VM, changed /usr/lib/vmware-wcp/objects/PodVM-GuestCluster/30-vmop/vmop.yaml file to add rbac permissions for appplatform (since vmop tar won't load those changes) and re-applied yaml
  3. Loaded vmop tar image using make docker-build, docker save docker.io/library/vmoperator-controller:latest > vmopfqdn.tar, and deploy-wcp.sh

Next, verified that web console returns API Server DNS name for login:

root@localhost [ ~ ]# kubectl vsphere vm web-console my-vm -n test-namespace
Successfully created a new WebConsoleRequest 'my-vm-b498r' in namespace 'test-namespace'
Waiting for the above WebConsoleRequest to be processed...

Web-Console URL: https://domain-1.test/vm/web-console?host=10.167.71.251&namespace=test-namespace&port=443&ticket=36fcf5b74000d104f4b3a5038381326f&uuid=77c1da1f-dbea-4bc2-af55-78303afc21d4
This URL is for one-time use and will expire at 2024-10-17T22:12:56Z (in about 2m0s)

Which issue(s) is/are addressed by this PR? (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):

Fixes #

Are there any special notes for your reviewer:

Please add a release note if necessary:


@github-actions github-actions bot added the size/L Denotes a PR that changes 100-499 lines. label Oct 7, 2024
@ammujumdar-bcom ammujumdar-bcom force-pushed the topic/ammujumdar/use-fqdn-if-given branch 4 times, most recently from 4296bf1 to 60882f1 Compare October 7, 2024 19:29
@github-actions github-actions bot added size/XL Denotes a PR that changes 500-999 lines. and removed size/L Denotes a PR that changes 100-499 lines. labels Oct 8, 2024
@ammujumdar-bcom ammujumdar-bcom force-pushed the topic/ammujumdar/use-fqdn-if-given branch from cdb36ef to 4f4742b Compare October 17, 2024 19:17
@ammujumdar-bcom ammujumdar-bcom changed the title 🐛 WIP: Use API Server DNS Names by default when logging into VM Web Console 🐛 Use API Server DNS Names by default when logging into VM Web Console Oct 18, 2024
@ammujumdar-bcom ammujumdar-bcom marked this pull request as ready for review October 18, 2024 20:15
Makefile Outdated Show resolved Hide resolved
}

// ProxyAddressFromVirtualIP retrieves the virtual IP, which will be used as the Proxy Address.
func (r *Reconciler) ProxyAddressFromVirtualIP(ctx *pkgctx.WebConsoleRequestContextV1) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

wondering if this method can also go into the pkg/util/webconsole/ now? @dilyar85 ?

Copy link
Contributor Author

@ammujumdar-bcom ammujumdar-bcom Oct 18, 2024

Choose a reason for hiding this comment

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

The thing is that the contexts for this and the v1alpha1 function are different data types. Does this matter?

If we move this to the webconsole directory, could we just use context.Context as the type?

Copy link
Contributor

@sreyasn sreyasn Oct 18, 2024

Choose a reason for hiding this comment

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

the contexts for this and the v1alpha1 function are different data types. Does this matter?

shouldn't matter. cause it's only doing client.Get() with the ctx.

could we just use context.Context as the type?

yep.

I'll let @dilyar85 comment if we need to keep it here or move.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved it for now.

Copy link
Member

Choose a reason for hiding this comment

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

Yep agree better to move to the util package (also commented on it below).

pkg/webconsoleurl/lookup.go Outdated Show resolved Hide resolved
@aruneshpa aruneshpa self-requested a review October 21, 2024 18:26
@ammujumdar-bcom ammujumdar-bcom force-pushed the topic/ammujumdar/use-fqdn-if-given branch from 641051a to 374470e Compare October 21, 2024 20:23
Copy link
Member

@dilyar85 dilyar85 left a comment

Choose a reason for hiding this comment

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

Thanks for adding this change to support the web console feature in Simplified Supervisor. Left some comments/suggestions and overall LGTM.

external/appplatform/api/v1alpha1/doc.go Outdated Show resolved Hide resolved
pkg/webconsoleurl/url_lookup.go Outdated Show resolved Hide resolved
pkg/webconsoleurl/url_lookup.go Outdated Show resolved Hide resolved
pkg/manager/manager.go Show resolved Hide resolved
pkg/webconsoleurl/url_lookup.go Outdated Show resolved Hide resolved
pkg/webconsoleurl/url_lookup.go Outdated Show resolved Hide resolved
pkg/webconsoleurl/url_lookup.go Outdated Show resolved Hide resolved
external/appplatform/api/v1alpha1/supervisorprops_types.go Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

I think a better place and name for this file could be pkg/util/proxy_address.go, as none of the functions inside are exclusive to the web console URL.

Also, can we add a test file for this? It should be easy to reach 100% CC since it simply gets the CR and returns the proxy address.

)
})

scenarios := []struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Using DescribeTable - https://onsi.github.io/ginkgo/#table-specs - is the more conventional way to write tests like this for Ginkgo.

Why is there a webconsolerequest.NewReconciler() in both the inner and outer JustBeforeEach()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I set the FSS in each iteration (in the same newreconciler call as the API Server DNS Name setting), then it will not actually set the FSS properly in fail. Hence, I do it up above.

Copy link
Contributor Author

@ammujumdar-bcom ammujumdar-bcom Oct 31, 2024

Choose a reason for hiding this comment

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

The problem that I am facing is that I am trying to modify the config (reconciler) just before each entry. It seems that JustBeforeEach and DescribeTable are not compatible with each other, so whenever I try to update proxySvcDNS within each Entry, the changes aren't actually going in affect.

onsi/ginkgo#1035

pkg/webconsoleurl/url_lookup.go Outdated Show resolved Hide resolved
pkg/webconsoleurl/url_lookup.go Outdated Show resolved Hide resolved
Copy link

Code Coverage

Package Line Rate Health
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/clustercontentlibraryitem 82%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/contentlibraryitem 85%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/utils 97%
github.com/vmware-tanzu/vm-operator/controllers/infra/capability/configmap 86%
github.com/vmware-tanzu/vm-operator/controllers/infra/capability/crd 93%
github.com/vmware-tanzu/vm-operator/controllers/infra/configmap 71%
github.com/vmware-tanzu/vm-operator/controllers/infra/node 77%
github.com/vmware-tanzu/vm-operator/controllers/infra/secret 77%
github.com/vmware-tanzu/vm-operator/controllers/infra/validatingwebhookconfiguration 85%
github.com/vmware-tanzu/vm-operator/controllers/infra/zone 76%
github.com/vmware-tanzu/vm-operator/controllers/storageclass 95%
github.com/vmware-tanzu/vm-operator/controllers/storagepolicyquota 97%
github.com/vmware-tanzu/vm-operator/controllers/util/encoding 73%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/storagepolicyusage 99%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/virtualmachine 86%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/volume 86%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineclass 75%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinepublishrequest 81%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinereplicaset 68%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice 83%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/providers 92%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinesetresourcepolicy 80%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha1 72%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha1/conditions 88%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha1/patch 78%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha2 72%
github.com/vmware-tanzu/vm-operator/pkg/bitmask 100%
github.com/vmware-tanzu/vm-operator/pkg/builder 95%
github.com/vmware-tanzu/vm-operator/pkg/conditions 88%
github.com/vmware-tanzu/vm-operator/pkg/config 100%
github.com/vmware-tanzu/vm-operator/pkg/config/capabilities 100%
github.com/vmware-tanzu/vm-operator/pkg/config/env 100%
github.com/vmware-tanzu/vm-operator/pkg/context/generic 100%
github.com/vmware-tanzu/vm-operator/pkg/context/operation 100%
github.com/vmware-tanzu/vm-operator/pkg/patch 78%
github.com/vmware-tanzu/vm-operator/pkg/prober 91%
github.com/vmware-tanzu/vm-operator/pkg/prober/probe 90%
github.com/vmware-tanzu/vm-operator/pkg/prober/worker 77%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere 75%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/client 80%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/clustermodules 71%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/config 89%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/contentlibrary 74%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/credentials 100%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/network 80%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/placement 79%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/session 71%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/storage 44%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/sysprep 100%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/vcenter 82%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/virtualmachine 84%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/vmlifecycle 67%
github.com/vmware-tanzu/vm-operator/pkg/record 78%
github.com/vmware-tanzu/vm-operator/pkg/topology 91%
github.com/vmware-tanzu/vm-operator/pkg/util 83%
github.com/vmware-tanzu/vm-operator/pkg/util/annotations 100%
github.com/vmware-tanzu/vm-operator/pkg/util/cloudinit 89%
github.com/vmware-tanzu/vm-operator/pkg/util/cloudinit/validate 91%
github.com/vmware-tanzu/vm-operator/pkg/util/image 100%
github.com/vmware-tanzu/vm-operator/pkg/util/kube 88%
github.com/vmware-tanzu/vm-operator/pkg/util/kube/cource 100%
github.com/vmware-tanzu/vm-operator/pkg/util/kube/internal 100%
github.com/vmware-tanzu/vm-operator/pkg/util/kube/spq 100%
github.com/vmware-tanzu/vm-operator/pkg/util/paused 100%
github.com/vmware-tanzu/vm-operator/pkg/util/ptr 100%
github.com/vmware-tanzu/vm-operator/pkg/util/resize 97%
github.com/vmware-tanzu/vm-operator/pkg/util/vmopv1 92%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/client 64%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/vm 79%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/watcher 86%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig 95%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/crypto 98%
github.com/vmware-tanzu/vm-operator/pkg/webconsolevalidation 100%
github.com/vmware-tanzu/vm-operator/services/vm-watcher 91%
github.com/vmware-tanzu/vm-operator/webhooks/common 100%
github.com/vmware-tanzu/vm-operator/webhooks/persistentvolumeclaim/validation 95%
github.com/vmware-tanzu/vm-operator/webhooks/unifiedstoragequota/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/mutation 87%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/validation 95%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/mutation 62%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinepublishrequest/validation 92%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinereplicaset/validation 90%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/mutation 67%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/validation 92%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesetresourcepolicy/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinewebconsolerequest/v1alpha1/validation 92%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinewebconsolerequest/v1alpha2/validation 92%
Summary 83% (10462 / 12605)

Minimum allowed line rate is 79%

@ammujumdar-bcom ammujumdar-bcom force-pushed the topic/ammujumdar/use-fqdn-if-given branch from 4f3d1dc to a3823cf Compare November 1, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XL Denotes a PR that changes 500-999 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants