kubernetes / minikube

Run Kubernetes locally
https://minikube.sigs.k8s.io/
Apache License 2.0
29.34k stars 4.88k forks source link

none: minikube service/dashboard should show URL instead of opening browser when run with sudo #3558

Closed Pacheco95 closed 5 years ago

Pacheco95 commented 5 years ago

Is this a BUG REPORT or FEATURE REQUEST? (choose one): BUG REPORT

Please provide the following details:

Environment:

System:    Host: MICHAEL-PC Kernel: 4.15.0-43-generic x86_64 bits: 64 compiler: gcc v: 7.3.0 
           Desktop: Cinnamon 4.0.9 wm: muffin dm: LightDM Distro: Linux Mint 19.1 Tessa 
           base: Ubuntu 18.04 bionic 
Machine:   Type: Desktop Mobo: ASUSTeK model: PRIME H370M-PLUS v: Rev 1.xx serial: <filter> 
           UEFI: American Megatrends v: 0904 date: 09/14/2018 
CPU:       Topology: 6-Core model: Intel Core i5-8600K bits: 64 type: MCP arch: Kaby Lake rev: A 
           L2 cache: 9216 KiB 
           flags: lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 43200 
           Speed: 800 MHz min/max: 800/4300 MHz Core speeds (MHz): 1: 800 2: 800 3: 800 4: 800 
           5: 800 6: 800 
Graphics:  Device-1: NVIDIA GP104 vendor: ASUSTeK driver: nvidia v: 390.77 bus ID: 01:00.0 
           chip ID: 10de:1b82 
           Display: x11 server: X.Org 1.19.6 driver: nvidia 
           unloaded: fbdev,modesetting,nouveau,vesa resolution: 1360x768~60Hz 
           OpenGL: renderer: GeForce GTX 1070 Ti/PCIe/SSE2 v: 4.6.0 NVIDIA 390.77 
           direct render: Yes 
Audio:     Device-1: Intel vendor: ASUSTeK driver: snd_hda_intel v: kernel bus ID: 00:1f.3 
           chip ID: 8086:a348 
           Device-2: NVIDIA GP104 High Definition Audio vendor: ASUSTeK driver: snd_hda_intel 
           v: kernel bus ID: 01:00.1 chip ID: 10de:10f0 
           Device-3: C-Media CM108 Audio Controller type: USB 
           driver: hid-generic,snd-usb-audio,usbhid bus ID: 1-10:5 chip ID: 0d8c:013c 
           Sound Server: ALSA v: k4.15.0-43-generic 
Network:   Device-1: Intel Ethernet I219-V vendor: ASUSTeK driver: e1000e v: 3.2.6-k port: efa0 
           bus ID: 00:1f.6 chip ID: 8086:15bc 
           IF: eno1 state: up speed: 100 Mbps duplex: full mac: <filter> 
           IF-ID-1: docker0 state: up speed: N/A duplex: N/A mac: <filter> 
           IF-ID-2: veth055496a state: up speed: 10000 Mbps duplex: full mac: <filter> 
           IF-ID-3: veth7b6e9d3 state: up speed: 10000 Mbps duplex: full mac: <filter> 
           IF-ID-4: veth7cdd50d state: up speed: 10000 Mbps duplex: full mac: <filter> 
           IF-ID-5: vetha85a82a state: up speed: 10000 Mbps duplex: full mac: <filter> 
Drives:    Local Storage: total: 931.51 GiB used: 29.07 GiB (3.1%) 
           ID-1: /dev/sda vendor: Seagate model: ST1000DX002-2DV162 size: 931.51 GiB 
           speed: 6.0 Gb/s serial: <filter> 
Partition: ID-1: / size: 93.37 GiB used: 11.53 GiB (12.4%) fs: ext4 dev: /dev/sda7 
           ID-2: /home size: 125.40 GiB used: 17.51 GiB (14.0%) fs: ext4 dev: /dev/sda8 
Sensors:   System Temperatures: cpu: 27.8 C mobo: N/A gpu: nvidia temp: 40 C 
           Fan Speeds (RPM): cpu: 0 gpu: nvidia fan: 0% 
Repos:     No active apt repos in: /etc/apt/sources.list 
           Active apt repos in: /etc/apt/sources.list.d/additional-repositories.list 
           1: deb [arch=amd64] https: //download.docker.com/linux/ubuntu bionic stable
           Active apt repos in: /etc/apt/sources.list.d/kubernetes.list 
           1: deb https: //apt.kubernetes.io/ kubernetes-xenial main
           Active apt repos in: /etc/apt/sources.list.d/official-package-repositories.list 
           1: deb http: //mirrors.evowise.com/linuxmint/packages tessa main upstream import backport
           2: deb http: //ubuntu-archive.locaweb.com.br/ubuntu bionic main restricted universe multiverse
           3: deb http: //ubuntu-archive.locaweb.com.br/ubuntu bionic-updates main restricted universe multiverse
           4: deb http: //ubuntu-archive.locaweb.com.br/ubuntu bionic-backports main restricted universe multiverse
           5: deb http: //security.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
           6: deb http: //archive.canonical.com/ubuntu/ bionic partner
           Active apt repos in: /etc/apt/sources.list.d/plushuang-tw-uget-stable-bionic.list 
           1: deb http: //ppa.launchpad.net/plushuang-tw/uget-stable/ubuntu bionic main
           2: deb-src http: //ppa.launchpad.net/plushuang-tw/uget-stable/ubuntu bionic main
Info:      Processes: 280 Uptime: 4h 45m Memory: 7.71 GiB used: 3.00 GiB (38.9%) Init: systemd 
           v: 237 runlevel: 5 Compilers: gcc: 7.3.0 alt: 7 Client: Unknown python3.6 client 
           inxi: 3.0.27 

Minikube version:

michael@MICHAEL-PC:~$ minikube version
minikube version: v0.33.1

- **ISO version**:

michael@MICHAEL-PC:~$ sudo cat ~/.minikube/machines/minikube/config.json | grep -i ISO

no output
- **Install tools**:
- **Others**:
<!-- The above can be generated in one go with the following commands (can be copied and pasted directly into your terminal):

minikube version echo ""; echo "OS:"; cat /etc/os-release echo ""; echo "VM driver:"; grep DriverName ~/.minikube/machines/minikube/config.json echo ""; echo "ISO version"; grep -i ISO ~/.minikube/machines/minikube/config.json

-->

**What happened**:
I'm following [this](https://kubernetes.io/docs/tutorials/hello-minikube/) tutorial steps, but when I tried to run the command `sudo minikube service hello-node` it gives me this error:

Opening kubernetes service default/hello-node in default browser... Running Firefox as root in a regular user's session is not supported. ($HOME is /home/michael which is owned by michael.) Running Firefox as root in a regular user's session is not supported. ($HOME is /home/michael which is owned by michael.) Running Firefox as root in a regular user's session is not supported. ($HOME is /home/michael which is owned by michael.) /usr/bin/xdg-open: 851: /usr/bin/xdg-open: iceweasel: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: seamonkey: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: mozilla: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: epiphany: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: konqueror: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: chromium: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: chromium-browser: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: google-chrome: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: www-browser: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: links2: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: elinks: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: links: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: lynx: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: w3m: not found xdg-open: no method available for opening 'http://192.168.2.110:32295'

Note: I can't run this command without sudo because permission denied error

**What you expected to happen**:
I don't know what does this command.

**How to reproduce it** (as minimally and precisely as possible):
The commands that I typed:

michael@MICHAEL-PC:~$ sudo kubectl create deployment hello-node --image=gcr.io/hello-minikube-zero-install/hello-node deployment.apps/hello-node created

michael@MICHAEL-PC:~$ sudo kubectl get deployments NAME READY UP-TO-DATE AVAILABLE AGE hello-node 0/1 1 0 13s

michael@MICHAEL-PC:~$ sudo kubectl get pods
NAME READY STATUS RESTARTS AGE hello-node-64c578bdf8-h4lkb 1/1 Running 0 64m

michael@MICHAEL-PC:~$ sudo kubectl get deployments NAME READY UP-TO-DATE AVAILABLE AGE hello-node 1/1 1 1 65m

michael@MICHAEL-PC:~$ sudo kubectl get events LAST SEEN TYPE REASON KIND MESSAGE 33m Normal Pulled Pod Successfully pulled image "gcr.io/hello-minikube-zero-install/hello-node" 33m Warning Failed Pod Error: cannot find volume "default-token-4jlfh" to mount into container "hello-node" 33m Normal Pulled Pod Successfully pulled image "gcr.io/hello-minikube-zero-install/hello-node" 33m Normal Created Pod Created container 33m Normal Started Pod Started container

michael@MICHAEL-PC:~$ sudo kubectl config view apiVersion: v1 clusters:

michael@MICHAEL-PC:~$ sudo kubectl expose deployment hello-node --type=LoadBalancer --port=8080 service/hello-node exposed

michael@MICHAEL-PC:~$ sudo kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-node LoadBalancer 10.99.154.58 8080:32295/TCP 30s kubernetes ClusterIP 10.96.0.1 443/TCP 3h5

michael@MICHAEL-PC:~$ sudo minikube service hello-node Opening kubernetes service default/hello-node in default browser... Running Firefox as root in a regular user's session is not supported. ($HOME is /home/michael which is owned by michael.) Running Firefox as root in a regular user's session is not supported. ($HOME is /home/michael which is owned by michael.) Running Firefox as root in a regular user's session is not supported. ($HOME is /home/michael which is owned by michael.) /usr/bin/xdg-open: 851: /usr/bin/xdg-open: iceweasel: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: seamonkey: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: mozilla: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: epiphany: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: konqueror: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: chromium: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: chromium-browser: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: google-chrome: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: www-browser: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: links2: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: elinks: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: links: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: lynx: not found /usr/bin/xdg-open: 851: /usr/bin/xdg-open: w3m: not found xdg-open: no method available for opening 'http://192.168.2.110:32295'



**Anything else do we need to know**: I'm using the flag `--vm-driver=none` and i think I read that when this flag is used the command must be executed with `sudo`
afbjorklund commented 5 years ago

You can use minikube service --url, if you want to use it with the unsupported none driver ?

--url Display the kubernetes service URL in the CLI instead of opening it in the default browser

But as long as you have the proper kube config, there is no need to run kubectl as the root user...

tstromberg commented 5 years ago

This is kind of a dupe of #2548 - but there is something we can do to make peoples lives easier here.

The issue is that your X environment isn't configured to allow apps from one user draw in your display environment. This could also be fixed by implementing https://github.com/kubernetes/minikube/issues/3138 - we should be complaining very loudly when people execute minikube as root.

fejta-bot commented 5 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

tstromberg commented 5 years ago

If anyone feels interest in fixing this issue, my recommendation would be to check if the current user id is 0 and simply display the URL here:

https://github.com/kubernetes/minikube/blob/68c546ff1da97190ec7d6bbe05b39da33de110f2/cmd/minikube/cmd/dashboard.go#L130

https://golang.org/pkg/os/user should help.

dpandhi-git commented 5 years ago

Would like to work on it