我的环境:k8s版本1.10。 kubectl版本1.10
Java客户端库:
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java</artifactId>
<version>1.0.0-beta4</version>
</dependency>
当我使用“kubectl create -f xxx.yml”时,部署已成功创建。但是使用API,得到“400 Bad Request”结果。没有其他有用的消息。 K8s API的结果总是给出很少的调试信息。 :(
以下是我部署的全部内容。
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-ingress-controller
namespace: ingress-nginx
spec:
replicas: 1
template:
metadata:
name: nginx-ingress-controller
labels:
app: nginx-ingress-controller
annotations:
prometheus.io/port: '10254'
prometheus.io/scrape: 'true'
spec:
serviceAccountName: nginx-ingress-serviceaccount
nodeSelector:
kubernetes.io/hostname: k8s-nginx-node0
tolerations:
- key: "app"
operator: "Equal"
value: "nginx-ingress-controller"
effect: "NoSchedule"
containers:
- name: nginx-ingress-controller
image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.13.0
volumeMounts:
- name: log-storage
mountPath: /var/log/nginx/
args:
- /nginx-ingress-controller
- --default-backend-service=$(POD_NAMESPACE)/nginx-ingress-controller
- --configmap=$(POD_NAMESPACE)/nginx-configuration
- --annotations-prefix=nginx.ingress.kubernetes.io
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
resources:
limits:
memory: "2000Mi"
cpu: 2
requests:
memory: "2000Mi"
cpu: 2
ports:
- name: http
containerPort: 80
hostPort: 80
- name: https
containerPort: 443
hostPort: 443
livenessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: 10254
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
readinessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: 10254
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
volumes:
- name: log-storage
hostPath:
path: /data/logs/nginx/
答案 0 :(得分:1)
谢谢@ewramner
setDebugging非常有用,可以节省我的时间。
根据我的部署对象,apiVersion: extensions/v1beta1
太旧了。更改为apiVersion: apps/v1beta2
解决了问题。