weaveworks / weave-gitops

Weave GitOps provides insights into your application deployments, and makes continuous delivery with GitOps easier to adopt and scale across your teams.
https://docs.gitops.weave.works/
Apache License 2.0
918 stars 153 forks source link

Dashboard port-forward is missing from session object annotations #3492

Closed opudrovs closed 1 year ago

opudrovs commented 1 year ago

When running GitOps Run in the session mode and after installing the dashboard for this session, the dashboard port-forward link does not appear in the enterprise UI in the port-forwards column.

The UI part looks OK, it just displays the links based on the session object annotations. It looks like the dashboard port-forward is not added to the session object annotations after the dashboard is successfully installed.

Before, the dashboard port-forward links in the UI were hard-coded, but they have been updated to be generated from session object annotations.

For the following command:

gitops run ./deploy/overlays/dev --timeout=3m --port-forward namespace=dev,resource=svc/backend,port=9898:9898

I get the following payload:

{
    "objects": [
        {
            "payload": "{\"apiVersion\":\"apps/v1\",\"kind\":\"StatefulSet\",\"metadata\":{\"annotations\":{\"meta.helm.sh/release-name\":\"run-master-1abc44f0\",\"meta.helm.sh/release-namespace\":\"default\",\"run.weave.works/automation-kind\":\"ks\",\"run.weave.works/cli-version\":\"v0.18.0-19-g3e1293c8\",\"run.weave.works/command\":\"gitops run ./deploy/overlays/dev --timeout=3m --port-forward namespace=dev,resource=svc/backend,port=9898:9898\",\"run.weave.works/flux-namespace\":\"flux-system\",\"run.weave.works/namespace\":\"default\",\"run.weave.works/port-forward\":\"9898\"},\"creationTimestamp\":\"2023-03-08T23:44:43Z\",\"generation\":1,\"labels\":{\"app\":\"vcluster\",\"app.kubernetes.io/managed-by\":\"Helm\",\"app.kubernetes.io/part-of\":\"gitops-run\",\"chart\":\"vcluster-0.14.2\",\"helm.toolkit.fluxcd.io/name\":\"run-master-1abc44f0\",\"helm.toolkit.fluxcd.io/namespace\":\"default\",\"heritage\":\"Helm\",\"release\":\"run-master-1abc44f0\"},\"managedFields\":[{\"apiVersion\":\"apps/v1\",\"fieldsType\":\"FieldsV1\",\"fieldsV1\":{\"f:metadata\":{\"f:annotations\":{\".\":{},\"f:meta.helm.sh/release-name\":{},\"f:meta.helm.sh/release-namespace\":{},\"f:run.weave.works/automation-kind\":{},\"f:run.weave.works/cli-version\":{},\"f:run.weave.works/command\":{},\"f:run.weave.works/flux-namespace\":{},\"f:run.weave.works/namespace\":{},\"f:run.weave.works/port-forward\":{}},\"f:labels\":{\".\":{},\"f:app\":{},\"f:app.kubernetes.io/managed-by\":{},\"f:app.kubernetes.io/part-of\":{},\"f:chart\":{},\"f:helm.toolkit.fluxcd.io/name\":{},\"f:helm.toolkit.fluxcd.io/namespace\":{},\"f:heritage\":{},\"f:release\":{}}},\"f:spec\":{\"f:podManagementPolicy\":{},\"f:replicas\":{},\"f:revisionHistoryLimit\":{},\"f:selector\":{},\"f:serviceName\":{},\"f:template\":{\"f:metadata\":{\"f:labels\":{\".\":{},\"f:app\":{},\"f:release\":{}}},\"f:spec\":{\"f:containers\":{\"k:{\\\"name\\\":\\\"syncer\\\"}\":{\".\":{},\"f:args\":{},\"f:env\":{\".\":{},\"k:{\\\"name\\\":\\\"CONFIG\\\"}\":{\".\":{},\"f:name\":{},\"f:value\":{}},\"k:{\\\"name\\\":\\\"POD_IP\\\"}\":{\".\":{},\"f:name\":{},\"f:valueFrom\":{\".\":{},\"f:fieldRef\":{}}},\"k:{\\\"name\\\":\\\"VCLUSTER_NODE_NAME\\\"}\":{\".\":{},\"f:name\":{},\"f:valueFrom\":{\".\":{},\"f:fieldRef\":{}}}},\"f:image\":{},\"f:imagePullPolicy\":{},\"f:livenessProbe\":{\".\":{},\"f:failureThreshold\":{},\"f:httpGet\":{\".\":{},\"f:path\":{},\"f:port\":{},\"f:scheme\":{}},\"f:initialDelaySeconds\":{},\"f:periodSeconds\":{},\"f:successThreshold\":{},\"f:timeoutSeconds\":{}},\"f:name\":{},\"f:readinessProbe\":{\".\":{},\"f:failureThreshold\":{},\"f:httpGet\":{\".\":{},\"f:path\":{},\"f:port\":{},\"f:scheme\":{}},\"f:periodSeconds\":{},\"f:successThreshold\":{},\"f:timeoutSeconds\":{}},\"f:resources\":{\".\":{},\"f:limits\":{\".\":{},\"f:cpu\":{},\"f:memory\":{}},\"f:requests\":{\".\":{},\"f:cpu\":{},\"f:memory\":{}}},\"f:securityContext\":{\".\":{},\"f:allowPrivilegeEscalation\":{}},\"f:terminationMessagePath\":{},\"f:terminationMessagePolicy\":{},\"f:volumeMounts\":{\".\":{},\"k:{\\\"mountPath\\\":\\\"/data\\\"}\":{\".\":{},\"f:mountPath\":{},\"f:name\":{},\"f:readOnly\":{}},\"k:{\\\"mountPath\\\":\\\"/manifests/coredns\\\"}\":{\".\":{},\"f:mountPath\":{},\"f:name\":{},\"f:readOnly\":{}}}},\"k:{\\\"name\\\":\\\"vcluster\\\"}\":{\".\":{},\"f:args\":{},\"f:command\":{},\"f:env\":{\".\":{},\"k:{\\\"name\\\":\\\"SERVICE_CIDR\\\"}\":{\".\":{},\"f:name\":{},\"f:valueFrom\":{\".\":{},\"f:configMapKeyRef\":{}}}},\"f:image\":{},\"f:imagePullPolicy\":{},\"f:name\":{},\"f:resources\":{\".\":{},\"f:limits\":{\".\":{},\"f:memory\":{}},\"f:requests\":{\".\":{},\"f:cpu\":{},\"f:memory\":{}}},\"f:securityContext\":{\".\":{},\"f:allowPrivilegeEscalation\":{}},\"f:terminationMessagePath\":{},\"f:terminationMessagePolicy\":{},\"f:volumeMounts\":{\".\":{},\"k:{\\\"mountPath\\\":\\\"/data\\\"}\":{\".\":{},\"f:mountPath\":{},\"f:name\":{}},\"k:{\\\"mountPath\\\":\\\"/etc/rancher\\\"}\":{\".\":{},\"f:mountPath\":{},\"f:name\":{}}}}},\"f:dnsPolicy\":{},\"f:restartPolicy\":{},\"f:schedulerName\":{},\"f:securityContext\":{},\"f:serviceAccount\":{},\"f:serviceAccountName\":{},\"f:terminationGracePeriodSeconds\":{},\"f:volumes\":{\".\":{},\"k:{\\\"name\\\":\\\"config\\\"}\":{\".\":{},\"f:emptyDir\":{},\"f:name\":{}},\"k:{\\\"name\\\":\\\"coredns\\\"}\":{\".\":{},\"f:configMap\":{\".\":{},\"f:defaultMode\":{},\"f:name\":{}},\"f:name\":{}}}}},\"f:updateStrategy\":{\"f:rollingUpdate\":{\".\":{},\"f:partition\":{}},\"f:type\":{}},\"f:volumeClaimTemplates\":{}}},\"manager\":\"helm-controller\",\"operation\":\"Update\",\"time\":\"2023-03-08T23:44:43Z\"},{\"apiVersion\":\"apps/v1\",\"fieldsType\":\"FieldsV1\",\"fieldsV1\":{\"f:status\":{\"f:availableReplicas\":{},\"f:collisionCount\":{},\"f:currentReplicas\":{},\"f:currentRevision\":{},\"f:observedGeneration\":{},\"f:readyReplicas\":{},\"f:replicas\":{},\"f:updateRevision\":{},\"f:updatedReplicas\":{}}},\"manager\":\"kube-controller-manager\",\"operation\":\"Update\",\"subresource\":\"status\",\"time\":\"2023-03-08T23:45:00Z\"}],\"name\":\"run-master-1abc44f0\",\"namespace\":\"default\",\"resourceVersion\":\"60969\",\"uid\":\"90d70ce6-6aba-444c-8039-fb46c5048e1a\"},\"spec\":{\"podManagementPolicy\":\"OrderedReady\",\"replicas\":1,\"revisionHistoryLimit\":10,\"selector\":{\"matchLabels\":{\"app\":\"vcluster\",\"release\":\"run-master-1abc44f0\"}},\"serviceName\":\"run-master-1abc44f0-headless\",\"template\":{\"metadata\":{\"creationTimestamp\":null,\"labels\":{\"app\":\"vcluster\",\"release\":\"run-master-1abc44f0\"}},\"spec\":{\"containers\":[{\"args\":[\"-c\",\"/bin/k3s server --write-kubeconfig=/data/k3s-config/kube-config.yaml --data-dir=/data --disable=traefik,servicelb,metrics-server,local-storage,coredns --disable-network-policy --disable-agent --disable-cloud-controller --flannel-backend=none --disable-scheduler --kube-controller-manager-arg=controllers=*,-nodeipam,-nodelifecycle,-persistentvolume-binder,-attachdetach,-persistentvolume-expander,-cloud-node-lifecycle,-ttl --kube-apiserver-arg=endpoint-reconciler-type=none --service-cidr=$(SERVICE_CIDR) \\u0026\\u0026 true\"],\"command\":[\"/bin/sh\"],\"env\":[{\"name\":\"SERVICE_CIDR\",\"valueFrom\":{\"configMapKeyRef\":{\"key\":\"cidr\",\"name\":\"vc-cidr-run-master-1abc44f0\"}}}],\"image\":\"rancher/k3s:v1.26.0-k3s1\",\"imagePullPolicy\":\"IfNotPresent\",\"name\":\"vcluster\",\"resources\":{\"limits\":{\"memory\":\"2Gi\"},\"requests\":{\"cpu\":\"200m\",\"memory\":\"256Mi\"}},\"securityContext\":{\"allowPrivilegeEscalation\":false},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"volumeMounts\":[{\"mountPath\":\"/etc/rancher\",\"name\":\"config\"},{\"mountPath\":\"/data\",\"name\":\"data\"}]},{\"args\":[\"--name=run-master-1abc44f0\",\"--service-account=vc-workload-run-master-1abc44f0\",\"--kube-config-context-name=my-vcluster\",\"--leader-elect=false\",\"--sync=-ingressclasses\",\"--rewrite-host-paths=true\",\"--map-virtual-service=gitops-run/run-dev-bucket=run-master-1abc44f0-bucket\"],\"env\":[{\"name\":\"POD_IP\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"status.podIP\"}}},{\"name\":\"VCLUSTER_NODE_NAME\",\"valueFrom\":{\"fieldRef\":{\"apiVersion\":\"v1\",\"fieldPath\":\"spec.nodeName\"}}},{\"name\":\"CONFIG\",\"value\":\"---\"}],\"image\":\"loftsh/vcluster:0.14.2\",\"imagePullPolicy\":\"IfNotPresent\",\"livenessProbe\":{\"failureThreshold\":60,\"httpGet\":{\"path\":\"/healthz\",\"port\":8443,\"scheme\":\"HTTPS\"},\"initialDelaySeconds\":60,\"periodSeconds\":2,\"successThreshold\":1,\"timeoutSeconds\":1},\"name\":\"syncer\",\"readinessProbe\":{\"failureThreshold\":60,\"httpGet\":{\"path\":\"/readyz\",\"port\":8443,\"scheme\":\"HTTPS\"},\"periodSeconds\":2,\"successThreshold\":1,\"timeoutSeconds\":1},\"resources\":{\"limits\":{\"cpu\":\"1\",\"memory\":\"512Mi\"},\"requests\":{\"cpu\":\"20m\",\"memory\":\"64Mi\"}},\"securityContext\":{\"allowPrivilegeEscalation\":false},\"terminationMessagePath\":\"/dev/termination-log\",\"terminationMessagePolicy\":\"File\",\"volumeMounts\":[{\"mountPath\":\"/manifests/coredns\",\"name\":\"coredns\",\"readOnly\":true},{\"mountPath\":\"/data\",\"name\":\"data\",\"readOnly\":true}]}],\"dnsPolicy\":\"ClusterFirst\",\"restartPolicy\":\"Always\",\"schedulerName\":\"default-scheduler\",\"securityContext\":{},\"serviceAccount\":\"vc-run-master-1abc44f0\",\"serviceAccountName\":\"vc-run-master-1abc44f0\",\"terminationGracePeriodSeconds\":10,\"volumes\":[{\"emptyDir\":{},\"name\":\"config\"},{\"configMap\":{\"defaultMode\":420,\"name\":\"run-master-1abc44f0-coredns\"},\"name\":\"coredns\"}]}},\"updateStrategy\":{\"rollingUpdate\":{\"partition\":0},\"type\":\"RollingUpdate\"},\"volumeClaimTemplates\":[{\"apiVersion\":\"v1\",\"kind\":\"PersistentVolumeClaim\",\"metadata\":{\"creationTimestamp\":null,\"name\":\"data\"},\"spec\":{\"accessModes\":[\"ReadWriteOnce\"],\"resources\":{\"requests\":{\"storage\":\"5Gi\"}},\"volumeMode\":\"Filesystem\"},\"status\":{\"phase\":\"Pending\"}}]},\"status\":{\"availableReplicas\":1,\"collisionCount\":0,\"currentReplicas\":1,\"currentRevision\":\"run-master-1abc44f0-6d848ff797\",\"observedGeneration\":1,\"readyReplicas\":1,\"replicas\":1,\"updateRevision\":\"run-master-1abc44f0-6d848ff797\",\"updatedReplicas\":1}}\n",
            "clusterName": "management",
            "tenant": "",
            "uid": "90d70ce6-6aba-444c-8039-fb46c5048e1a",
            "inventory": [],
            "info": "session objects created"
        }
    ],
    "errors": []
}

As you can see, the dashboard port-forward is not added to the annotations, from which we add the links to the UI, although it is successfully displayed in the CLI in the list of port-forwards.

LappleApple commented 1 year ago

@chanwit can point @luizbafilho to the code that maybe the cause of this issue.