Score:0

How to perform a port-forward on microk8s and send that process to the background?

ru flag

I am trying to run this command:

microk8s kubectl port-forward -n kube-system service/kubernetes-dashboard 10443:443

But the output is the following:

└─[$] <> microk8s kubectl port-forward -n kube-system service/kubernetes-dashboard 10443:443
Forwarding from 127.0.0.1:10443 -> 8443
Forwarding from [::1]:10443 -> 8443

And this is a "always on" process, is there anyway to perform this configuration without me having to keep a terminal open?

Score:1
in flag

I'm not familiar with microk8s specifically, but if it behaves like a standard k8s system, then you could create another Service using type NodePort. That would expose the dashboard on a local port on the kubernetes node.

kind: Service
apiVersion: v1
metadata:
  name: k8s-dash
  namespace: kube-system
spec:
  selector:
    app: k8s-dash
  type: NodePort
  ports:
  - name: https
    nodePort: 30443
    port: 443
    targetPort: 443
    protocol: TCP

Change the selector to match what ever the labels the dashboard uses.

Alternatively you could deploy an Ingress Controller (like this one: https://github.com/nginxinc/kubernetes-ingress ) and use an Ingress resource to expose it.

The ingress controller is the more secure route, because you can apply additional protections like ACL, OAUTH2, etc.

Score:0
cn flag

Though I am not much familiar with Kubernetes, but a general way to keep a command running in background is by using nohup at the beginning and & at the end.

e.g.

nohup microk8s kubectl port-forward -n kube-system service/kubernetes-dashboard 10443:443 &

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.