在Ryan Baxter的Spring On Kubernetes workshop之后,我遇到了无法解决的问题。在“部署到Kubernetes”的步骤中,生成depoyment.yaml和services.yaml文件后,我运行
kubectl apply -f ./k8s
我收到验证错误:
error validating "k8s/deployment.yaml": error validating data: the server could not find the requested resource; if you choose to ignore these errors,turn validation off with --validate=false
error validating "k8s/service.yaml": error validating data: the server could not find the requested resource; if you choose to ignore these errors,turn validation off with --validate=false
运行后
kubectl apply -f ./k8s --validate = false
我知道
error: unable to recognize "k8s/deployment.yaml": no matches for extensions/,Kind=Deployment
service"my-app" created
这是yaml文件:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: my-app
name: my-app
spec:
replicas: 1
selector:
matchLabels:
app: my-app
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: my-app
spec:
containers:
- image: docker.io/my-id/my-app
name: my-app
resources: {}
status: {}
根据Harsh的建议,我将apiVersion更改为apps / v1,然后再次运行kubectl apply命令。
deployment "my-app" created
service "my-app" configured
根据手表显示的内容,我跑步
kubectl port-forward svc/my-app 8080:80
手表中显示svc / my-app的位置。它产生
error: invalid resource name svc/my-app: [may not contain '/']
要清理,我运行
kubectl delete -f ./k8s
它产生
service "my-app" deleted
Error from server (NotFound): error when stopping "k8s/deployment.yaml": the server could not find the requested resource
我不知道这些问题是由我的操作错误还是某些错误引起的。