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

add route/ingress URL to .status #514

Merged
merged 1 commit into from
Feb 3, 2022
Merged

add route/ingress URL to .status #514

merged 1 commit into from
Feb 3, 2022

Conversation

reginapizza
Copy link
Collaborator

@reginapizza reginapizza commented Dec 13, 2021

What type of PR is this?
/kind enhancement

What does this PR do / why we need it:
This would add a new field, .host, to .status of ArgoCD. When route or ingress is enabled (priority given to route) then the route will be displayed in the new URL field.

When no URL exists from a route or ingress, the field will not be displayed.

When on a non-OpenShift cluster (meaning the Route API is not available), if the user chooses to enable Route, they will only get a log saying that Routes are not available in non-OpenShift environments and to please use Ingresses instead. The state of the application controller and of the URL will not be affected.

When the route or ingress is configured, but the corresponding controller has not yet set it up properly (i.e. is not in Ready state or does not propagate its URL), this is indicated in the Operand as well in the value of .status.url as Pending instead of the URL. Also, if .status.url is Pending, this affects the overall status for the Operand by making it Pending instead of Available.

Have you updated the necessary documentation?

  • Documentation update is required by this PR.
  • Documentation has been updated.

Which issue(s) this PR fixes:
Fixes #246

How to test changes / Special notes to the reviewer:

Special Notes to the reviewer:

Whatever your cluster is, make sure that Ingress Controller is installed, enabled and running before moving forward. Instructions for ingress-controller for the following types of cluster are:

  1. kind : https://abhishekveeramalla-av.medium.com/run-argo-cd-using-operator-on-kind-e59f48687d38
  2. minikube: run command minikube addons enable ingress
  3. k3d: Traefik Ingress Controller is installed/enabled by default
  4. OpenShift: after enabling ingress in Argo CD spec, update the following on the ingress spec:
    • remove Nginx annotations
    • update hostame to example-argocd.yourcluster.example.com where example-argocd is the argocd host

Ingress Testing:

  1. Get cluster and log in (I used a K3D cluster for this).

  2. In your cloned repo on this branch, go to Makefile and change the version # (just to something else) and change image base tag to IMAGE_TAG_BASE ?= quay.io/{your quay or docker username}/argocd-operator. Then run make docker-build, make docker-pushand login to a cluster and then run make deploy

  3. Add the Argo CD instance:

cat <<EOF | kubectl apply -f -                                                                    
apiVersion: argoproj.io/v1alpha1
kind: ArgoCD
metadata:
  name: argocd
spec: {}
EOF   
  1. Create an Ingress:
cat <<EOF | oc apply -f -                                                                    
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: argocd-server
spec:
  rules:
  - host: argocd
    http:
      paths:
      - backend:
          service:
            name: argocd-server
            port:
              number: 8080
        path: /
        pathType: ImplementationSpecific
EOF

If you do oc get ingress argocd-server you should see:

NAME            CLASS    HOSTS    ADDRESS      PORTS   AGE
argocd-server   <none>   argocd   172.22.0.3   80      9m56s
  1. Edit the ArgoCD instance so that ingress and route (or at least just route if you're on an OpenShift cluster) is enabled with oc edit argocd argocd. spec.server should look something like:
  server:
    autoscale:
      enabled: false
    grpc:
      ingress:
        enabled: false
    ingress:
      enabled: true
    route:
      enabled: false
    service:
      type: ""
  tls:
    ca: {}

Save your changes.

  1. Wait a second for it to update, and then check back on your CR oc get argocd argocd -o yaml. You should see that the URL has been added to the .status field.
status:
  applicationController: Running
  dex: Running
  host: 172.22.0.3
  phase: Available
  redis: Running
  repo: Running
  server: Running
  ssoConfig: Unknown

Route Testing:

  1. Get cluster and log in (I used an OpenShift cluster for this since routes are specific to OpenShift, if the Route API is not available this functionality will not work).

  2. In your cloned repo on this branch, go to Makefile and change the version # (just to something else) and change image base tag to IMAGE_TAG_BASE ?= quay.io/{your quay or docker username}/argocd-operator. Then run make docker-build, make docker-pushand login to a cluster and then run make deploy

  3. Add the Argo CD instance:

cat <<EOF | kubectl apply -f -                                                                    
apiVersion: argoproj.io/v1alpha1
kind: ArgoCD
metadata:
  name: argocd
spec: {}
EOF   
  1. Edit the ArgoCD instance so that ingress and route (or at least just route if you're on an OpenShift cluster) is enabled with oc edit argocd argocd. spec.server should look something like:
  server:
    autoscale:
      enabled: false
    grpc:
      ingress:
        enabled: false
    ingress:
      enabled: false
    route:
      enabled: true
    service:
      type: ""
  tls:
    ca: {}

Save your changes.
5. Wait a second for it to update, and then check back on your CR oc get argocd argocd -o yaml. You should see that the URL has been added to the .status field.

status:
  applicationController: Running
  dex: Running
  host: argocd-server-default.apps.app-svc-4.8-120914.devcluster.openshift.com
  phase: Available
  redis: Running
  repo: Running
  server: Running
  ssoConfig: Unknown

Note: If route and ingress are both enabled, the route (if available) will have preference over ingress.

controllers/argocd/deployment.go Outdated Show resolved Hide resolved
controllers/argocd/status.go Outdated Show resolved Hide resolved
controllers/argocd/status.go Outdated Show resolved Hide resolved
@iam-veeramalla
Copy link
Collaborator

@reginapizza please run make bundle and resubmit the file 0.2.0/argoproj.io_argocds.yaml, my bad that I asked you to uncommit that file.

@jaideepr97
Copy link
Collaborator

would it be a good idea to mention that the created route/ingress URL can be retrieved from the ArgoCD instance's .status.URL field in https://argocd-operator.readthedocs.io/en/latest/usage/ingress/ and https://argocd-operator.readthedocs.io/en/latest/usage/routes/?

@reginapizza

@jaideepr97
Copy link
Collaborator

On further thought, a couple of cases occurred to me that I'm wondering how/if we should handle:

  1. If someone tries to set .spec.server.route: enabled in a k8s cluster, this might throw an error. Maybe we should add a check for the route API here and fail silently instead?

  2. Do we want to allow users to be able to set both route and ingress to enabled? If Both route and ingress are enabled on Openshift, is there a possibility we could end up with 2 routes for the same server? (One created by the operator, the other created by the openshift router automatically from the ingress) In that case should we just allow the route created by the router?
    Let me know what you think @reginapizza @iam-veeramalla

@reginapizza
Copy link
Collaborator Author

@jaideepr97 I've updated my PR to address your first concern, but I'm still not sure about the second. @iam-veeramalla do you think that it's a concern?

@jaideepr97
Copy link
Collaborator

LGTM
Thanks @reginapizza !!

cr.Status.Phase = status
return r.Client.Status().Update(context.TODO(), cr)
} else {
cr.Status.URL = route.Spec.Host
Copy link
Collaborator

@wtam2018 wtam2018 Dec 23, 2021

Choose a reason for hiding this comment

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

We should get the host from route.Status.Ingress which is a list of RouteIngresses. I think we should show all the ingresses.

Also, each ingress has a status. If any of the ingresses is in failed status, should cr.Status.Phase be set to failed?

@reginapizza reginapizza changed the title add route/ingress URL to .status WIP: add route/ingress URL to .status Dec 23, 2021
@reginapizza reginapizza changed the title WIP: add route/ingress URL to .status add route/ingress URL to .status Jan 27, 2022
@wtam2018
Copy link
Collaborator

wtam2018 commented Feb 1, 2022

Ingress and route can be enabled at the same time. However, the status does not show ingress if route is enabled. WDYT @jaideepr97 @iam-veeramalla @reginapizza Should status be honest about showing ingress as well? We can probably just document as such.

@jaideepr97
Copy link
Collaborator

Per my understanding, on openshift environments routes are given more importance than ingresses (since a route is created automatically for each ingress) so I would say it makes sense to just show the route and document that the ingress is not shown in this case

On a related note, if both route and ingress are enabled we might end up with 2 routes for the same server deployment
Is this a case we want to handle?

@wtam2018
Copy link
Collaborator

wtam2018 commented Feb 3, 2022

@jaideepr97 It is also my understanding. https://docs.openshift.com/container-platform/4.6/networking/routes/route-configuration.html#nw-ingress-creating-a-route-via-an-ingress_route-configuration You can annotate an Ingress and OpenShift can create a Route automatically,
The question came up for the case where both ingress and route are legitimately enabled by the user in the Argo CD CR. We are only showing the status of Route. The ingress does not have the annotation.
I think we just need to document that only the route status is displaced when both ingress and route are enabled.

Copy link
Collaborator

@jannfis jannfis left a comment

Choose a reason for hiding this comment

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

LGTM

@jannfis jannfis merged commit 808d0a2 into argoproj-labs:master Feb 3, 2022
log.Info("argocd-server ingress requested but not found on cluster")
return nil
} else {
if !reflect.DeepEqual(ingress.Status.LoadBalancer, corev1.LoadBalancerStatus{}) && len(ingress.Status.LoadBalancer.Ingress) > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@reginapizza @jannfis I can''t figure out why is the DeepEqual() is needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

would if !reflect.ValueOf(ingress.Status.LoadBalancer).IsZero() && len(ingress.Status.LoadBalancer.Ingress) > 0 { be better?

Copy link
Collaborator

@wtam2018 wtam2018 Feb 3, 2022

Choose a reason for hiding this comment

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

Yes, IsZero a bit cleaner and faster then DeepCopy and && len(ingress.Status.LoadBalancer.Ingress) > 0 can be eliminated. Leaving it as-is is fine.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should keep the len(ingress.Status.LoadBalancer.Ingress) > 0 as a sanity check, to make sure code only executes if we have at least 1 proper ingress hostname/ip to work with

@wtam2018
Copy link
Collaborator

wtam2018 commented Feb 3, 2022

@reginapizza please update how to test o include testing the ingress only case.

@reginapizza
Copy link
Collaborator Author

@wtam2018 I've updated the instructions on how to test ingresses with it!

wtam2018 added a commit that referenced this pull request Mar 4, 2022
* Improve docs for custom roles feature (#548)

* add route/ingress host to .status (#514)

* fix: argocd-tls-certs-cm is overwritten on any change (#553)

Signed-off-by: iam-veeramalla <abhishek.veeramalla@gmail.com>

* add docs for host field in .status (#554)

* GITOPS-1550 removed unnecessary roles/rolebindings for target namespace (#557)

* chore(deps): bump github.com/argoproj/argo-cd/v2 from 2.2.2 to 2.2.4 (#560)

Bumps [github.com/argoproj/argo-cd/v2](https://github.com/argoproj/argo-cd) from 2.2.2 to 2.2.4.
- [Release notes](https://github.com/argoproj/argo-cd/releases)
- [Changelog](https://github.com/argoproj/argo-cd/blob/master/CHANGELOG.md)
- [Commits](argoproj/argo-cd@v2.2.2...v2.2.4)

---
updated-dependencies:
- dependency-name: github.com/argoproj/argo-cd/v2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix: update operator capabilities level in CSV (#549)

* feat: bump argo cd to version 2.2.5

* feat: update bundle and manifests to v0.3.0

* Update deploy/olm-catalog/argocd-operator/0.2.0/argocd-operator.v0.2.0.clusterserviceversion.yaml

Co-authored-by: jannfis <jann@mistrust.net>

* Update config/manifests/bases/argocd-operator.clusterserviceversion.yaml

Co-authored-by: jannfis <jann@mistrust.net>

* Update bundle/manifests/argocd-operator.clusterserviceversion.yaml

Co-authored-by: jannfis <jann@mistrust.net>

Co-authored-by: Chetan Banavikalmutt <chetanrns1997@gmail.com>
Co-authored-by: Regina Scott <50851526+reginapizza@users.noreply.github.com>
Co-authored-by: Yi Cai <yicai@redhat.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jaideep Raghunath Rao <jaideep.r97@gmail.com>
Co-authored-by: William Tam <wtam@redhat.com>
Co-authored-by: jannfis <jann@mistrust.net>
@iam-veeramalla
Copy link
Collaborator

Known Issue:
@ishitasequeira and I have noticed that this feature does not work as expected when Argo CD server is exposed using an Ingress resource(instead of route) on an OpenShift cluster. Please refer to the issue or JIRA for more details.

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

Successfully merging this pull request may close these issues.

Add the ingress/route URL to .status
5 participants