I'm getting deprecation errors while trying to run a couple of nginx pods
bash-4.4$ kubectl run nginx --image=nginx --port=80 --replicas=3
WARNING: New generator "deployment/apps.v1beta1" specified, but it isn't available. Falling back to "deployment/v1beta1".
kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed in a future version. Use kubectl create instead.
error: no matches for kind "Deployment" in version "apps/v1beta1"
While attempting to add the apps generator I also hit a snag...
bash-4.4$ kubectl run nginx --image=nginx --port=80 --replicas=3 --generator=deployment/apps.v1beta1
kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed in a future version. Use kubectl create instead.
error: no matches for kind "Deployment" in version "apps/v1beta1"
Not really certain what is going on, I'm just trying a simple hello world, here's the playbook that deploys and exposes
---
#######################################
# Deploy and expose Nginx service
#######################################
# Expects kubectl being configured on the local machine
# using kubectl.yml playbook
- hosts: localhost
connection: local
tasks:
- name: Launch 3 nginx pods
command: "kubectl run nginx --image=nginx --port=80 --replicas=3"
# command: "kubectl create deployment nginx --image=nginx --generator=deployment-basic/v1beta1"
- name: Expose nginx
command: "kubectl expose deployment nginx --type NodePort"
- name: Get exposed port
command: "kubectl get svc nginx --output=jsonpath='{range .spec.ports[0]}{.nodePort}'"
register: result
- set_fact:
node_port: "{{ result.stdout }}"
- debug: msg="Exposed port {{ node_port }}"
And here is some background on the cluster and versions etc
bash-4.4$ kubectl version
Client Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.2", GitCommit:"17c77c7898218073f14c8d573582e8d2313dc740", GitTreeState:"clean", BuildDate:"2018-10-30T21:39:38Z", GoVersion:"go1.11.1", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.6", GitCommit:"ae4550cc9c89a593bcda6678df201db1b208133b", GitTreeState:"clean", BuildDate:"2016-08-26T18:06:06Z", GoVersion:"go1.6.2", Compiler:"gc", Platform:"linux/amd64"}
bash-4.4$ kubectl get componentstatus
NAME STATUS MESSAGE ERROR
controller-manager Healthy ok
scheduler Healthy ok
etcd-1 Healthy {"health": "true"}
etcd-2 Healthy {"health": "true"}
etcd-0 Healthy {"health": "true"}
Help would be greatly appreciated, I'm holding up some guys at a hackathon ;)
You have a very large mismatch over kubectl
and Kubernetes cluster versions (1.12.2 vs 1.3.6). I recommend you download kubectl
1.3.6. If you are using Linux:
$ wget https://dl.k8s.io/v1.3.6/kubernetes-client-linux-amd64.tar.gz
$ tar zxvf kubernetes-client-linux-amd64.tar.gz
Or MacOS:
$ wget https://dl.k8s.io/v1.3.6/kubernetes-client-darwin-amd64.tar.gz
$ tar zxvf kubernetes-client-darwin-amd64.tar.gz