Accessing Pod Information Using Public IP Address in Kubernete

I can get information about Pods using http: // localhost: 8001 / api / v1 / pods from inside my cluster.

Is there a way to get pod information using http: // master-public-ip: 8001 / api / v1 / pods ?

+3


source to share


1 answer


By default, the wizard only exposes HTTPS to the public Internet, not HTTP. You can click https://admin:password@master-public-ip/api/v1/pods/

where password

is the generated password for the admin user. This can be found either in a file .kube/config

on your computer or in a file /srv/kubernetes/known_tokens.csv

on the main server.

eg. on the main VM:

$ cat /srv/kubernetes/known_tokens.csv 
mYpASSWORD,admin,admin
unused,kubelet,kubelet
...

      

Or on your computer:



$ cat ~/.kube/config
...
- name: my-cluster
  user:
    client-certificate-data: ...
    client-key-data: ...
    password: mYpASSWORD
    username: admin
...

$ curl --insecure https://admin:mYpASSWORD@master-public-ip/api/v1/pods/
...

      

To avoid use --insecure

(i.e. actually check the server certificate that your master represents), you can use a flag --cacert

to specify the authority of the cluster CA from your file .kube/config

.

$ cat ~/.kube/config
...
- cluster:
    certificate-authority-data: bIgLoNgBaSe64eNcOdEdStRiNg
    server: https://master-public-ip
  name: my-cluster
...

$ echo bIgLoNgBaSe64eNcOdEdStRiNg | base64 -d > ca.crt

$ curl --cacert=ca.crt https://admin:mYpASSWORD@master-public-ip/api/v1/pods/
...

      

+2


source







All Articles