我安装了kubernetes
使用kubeadm
和kube-apiserver
启动成功。我的电脑的操作系统是Centos 7。命令如下:
kube-apiserver
--advertise-address=10.211.55.9
--allow-privileged=true
--authorization-mode=Node,RBAC
--client-ca-file=/etc/kubernetes/pki/ca.crt
--enable-admission-plugins=NodeRestriction
--enable-bootstrap-token-auth=true
--etcd-cafile=/etc/kubernetes/pki/etcd/ca.crt
--etcd-certfile=/etc/kubernetes/pki/apiserver-etcd-client.crt
--etcd-keyfile=/etc/kubernetes/pki/apiserver-etcd-client.key
--etcd-servers=https://127.0.0.1:2379
--insecure-port=0
--kubelet-client-certificate=/etc/kubernetes/pki/apiserver-kubelet-client.crt
--kubelet-client-key=/etc/kubernetes/pki/apiserver-kubelet-client.key
--kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
--proxy-client-cert-file=/etc/kubernetes/pki/front-proxy-client.crt
--proxy-client-key-file=/etc/kubernetes/pki/front-proxy-client.key
--requestheader-allowed-names=front-proxy-client
--requestheader-client-ca-file=/etc/kubernetes/pki/front-proxy-ca.crt
--requestheader-extra-headers-prefix=X-Remote-Extra-
--requestheader-group-headers=X-Remote-Group
--requestheader-username-headers=X-Remote-User
--secure-port=6443
--service-account-key-file=/etc/kubernetes/pki/sa.pub
--service-cluster-ip-range=10.96.0.0/12
--tls-cert-file=/etc/kubernetes/pki/apiserver.crt
--tls-private-key-file=/etc/kubernetes/pki/apiserver.key
--enable-swagger-ui=true
--insecure-bind-address=0.0.0.0
--insecure-port=8080
打开浏览器搜索http://localhost:8080/swagger-ui/
,我得到了没有swagger ui的uri列表。如何显示swagger ui?
http://localhost:8080/swagger-ui/
{
"paths": [
"/apis",
"/apis/",
"/apis/apiextensions.k8s.io",
"/apis/apiextensions.k8s.io/v1",
"/apis/apiextensions.k8s.io/v1beta1",
"/healthz",
"/healthz/etcd",
"/healthz/log",
"/healthz/ping",
"/healthz/poststarthook/crd-informer-synced",
"/healthz/poststarthook/generic-apiserver-start-informers",
"/healthz/poststarthook/start-apiextensions-controllers",
"/healthz/poststarthook/start-apiextensions-informers",
"/livez",
"/livez/etcd",
"/livez/log",
"/livez/ping",
"/livez/poststarthook/crd-informer-synced",
"/livez/poststarthook/generic-apiserver-start-informers",
"/livez/poststarthook/start-apiextensions-controllers",
"/livez/poststarthook/start-apiextensions-informers",
"/metrics",
"/openapi/v2",
"/readyz",
"/readyz/etcd",
"/readyz/log",
"/readyz/ping",
"/readyz/poststarthook/crd-informer-synced",
"/readyz/poststarthook/generic-apiserver-start-informers",
"/readyz/poststarthook/start-apiextensions-controllers",
"/readyz/poststarthook/start-apiextensions-informers",
"/readyz/shutdown",
"/version"
]
}
4条答案
按热度按时间bjp0bcyl1#
打开指向Kubernetes API服务器的反向代理:
保存Swagger文件。* 由于CORS策略,无法直接链接。*
使用Swagger UI启动一个Docker容器
参考:https://jonnylangefeld.com/blog/kubernetes-how-to-view-swagger-ui
如果您想充分发挥Swagger的潜力,本指南可能会帮助您:https://github.com/olivernadj/Kubernetes-REST-API-feat-Swagger-UI
wtlkbnrh2#
获取openapi json最简单的方法是:
现在你可以为这个json启动一个swagger-ui示例,如下所示:
导航到https://本地主机:8081
你会看到一个昂首阔步的用户界面,但它相当落后,因为Kubernetes集群公开了许多API。
0wi1tuuw3#
这里有一个快速的方法来玩swagger和k8s api。
不适用于生产。
Failed to load API definition
尽情享受https://swagger-ui/
UPD:如果您看到
Failed to load API definition
,请打开https://kubernetes/,单击Proceed to kubernetes (unsafe)
,然后重试https://swagger-ui/。否则,请确保按顺序执行步骤!
清洁:
k3d cluster delete
jjjwad0x4#
Kubernetes API服务器通过
/openapi/v2
端点为OpenAPI规范提供服务。