i need create an https url from my dash board using kubectl proxy is only generating http url how to create an https url what command should we run for that token is grtting generated but not login dashboards stays static with no response on entering the token
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can expose your kubernetes-dashboard
service via NodePort.
To achieve this, the simplest way would be to edit the current kubernetes-dashboard
service configuration and change ClusterIP
parameter to NodePort
:
kubectl edit services kubernetes-dashboard -n kube-system
apiVersion: v1
kind: Service
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"k8s-app":"kubernetes-dashboard"}
,"name":"kubernetes-dashboard","namespace":"kube-system"},"spec":{"ports":[{"port":443,"targetPort":8443}],"select
or":{"k8s-app":"kubernetes-dashboard"}}}
creationTimestamp: null
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
selfLink: /api/v1/namespaces/kube-system/services/kubernetes-dashboard
spec:
externalTrafficPolicy: Cluster
ports:
- port: 443
protocol: TCP
targetPort: 8443
selector:
k8s-app: kubernetes-dashboard
sessionAffinity: None
type: NodePort
status:
loadBalancer: {}
Kubernetes then allocates some port from range (30000-32767) and each node should proxy that port to your target service.
You can now check kubernetes-dashboard
and look for the port reference:
kubectl describe svc kubernetes-dashboard -n kube-system
Name: kubernetes-dashboard
Namespace: kube-system
Labels: k8s-app=kubernetes-dashboard
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","me
tadata":{"annotations":{},"labels":{"k8s-app":"kubernetes-dashboard"},"name":"kubernetes-dashboard","namespace":..
.
Selector: k8s-app=kubernetes-dashboard
Type: NodePort
IP: XX.XX.XX.XX
Port: <unset> 443/TCP
TargetPort: 8443/TCP
NodePort: <unset> 31605/TCP
Endpoints: XX.XX.XX.XX:8443
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
Finally, you can check whether kubernetes-dashboard
would be accessible:
curl -k https://localhost:31605
If you consider to secure a way to talk to your Kubernetes dashboard via Bearer token
then take a look at this guideline.