I am using Rancher 2.X. I have installed it on my local machine. I have also installed a local Kubernetes cluster using Minikube. When I try to create a cluster in Rancher UI and import the existing K8s cluster, I am asked to run the following command on my K8s cluster using kubectl:
kubectl apply -f https://10.41.124.40/v3/import/g2gk5ntvnlh8xtvlngjmxdt22cm6zgtfjhswgcqmhltpg9nt9pvgsc.yaml
But, when I run this command, I get this error:
error: SchemaError(io.k8s.api.core.v1.ComponentCondition): invalid object doesn’t have additional properties
What am I doing wrong?
Thanks!!!
Let try with this:
curl -sKL https://10.41.124.40:8443/v3/import/g2gk5ntvnlh8xtvlngjmxdt22cm6zgtfjhswgcqmhltpg9nt9pvgsc.yaml > /tmp/cluster.yaml && kubectl apply -f /tmp/cluster.yaml
Related
I am following a tutorial, where a pod is created using the below command:
kubectl run firstPod --image={image from dockerhub repository}
But I am getting the following error:
Error from server (Forbidden): pods "firstPod" is forbidden: error looking up service account default/default: serviceaccount "default" not found
The goal of command is to pull docker image from my own repository and use it to create pod. I saw already some solutions that use .yaml file (but I didn't like the answer). All I want is to run this command. I am using windows 10 and docker desktop for a kubernetes cluster (minikube etc.).
You can test it with network-multitool. It will keep on running a webserver and have a lot of great tools.
kubectl run multitool --image=praqma/network-multitool --replicas=1
If that works, find the podname
kubectl get pods
Then you can exec into it with the name you found above
kubectl exec -it multitool-3822887632-pwlr1 bash
From inside the container/pod you can tjek that the webserver is running by
curl localhost
If the first command doesnt work, then something is wrong.
Check if the service account exists
kubectl get sa
Thanks for answers. Now I realize, that I forget to start my local cluster minikube.
minikube start
Now it is ok to create a pod.
Post my latest Docker Update installation i am getting below error
PS C:\Users\vpasumar> docker ps -a
unable to resolve docker endpoint: default orchestrator is kubernetes but unable to resolve kubernetes endpoint: Error loading config file "C:\Users\vpasumar\.kube\config": yaml: control characters are not allowed
I see docker as running and kubernetes as 'starting' only. I did not start after much of time also.
Any idea, how to access docker.
It looks like you have docker stack defaulted to be deployed to Kubernetes in other words Kubernetes is the default orchestrator in your machine.
You can disable this easily from Docker Desktop settings/preferences, uncheck Deploy Docker Stacks to Kubernetes by default
I am using docker desktop 3.6.0 and i don't have option to select or unselect Default Stack.
However, Removing following statement from C:\Users\your user\.docker\config.json
"stackOrchestrator": "kubernetes"
Run any docker command again, it solves the problem.
I have removed the C:\Users\vpasumar\.kube\config file; the issue is now solved. I'm able to use docker command correctly.
If you're using Linux and looking to undo and reset the local environment
Try :
eval $(docker-machine env --unset)
You can refere to this answer of Elton Stoneman enter link description here
Hope this helps ^^
This should fix the issue:
kubectl config set-context docker-desktop
or
kubectl config set-context minikube
Docker needs a default kubernetes endpoint.
I uninstalled Docker and installed it again (using the stable release channel).
Is it normal that the command "kubectl cluster-info" shows the output:
Kubernetes master is running at https://localhost:6445
But Kubernetes is not enabled in the Docker settings.
Thanks.
I have reproduced your case.
If you install Docker on Windows10 without any other Kubernetes configuration it will return output:
$ kubectl cluster-info
Kubernetes master is running at http://localhost:8080
When you will enable Kubernetes in Docker for Windows you will receive output:
$ kubectl cluster-info
Kubernetes master is running at http://localhost:6445
KubeDNS is running at https://localhost:6445/api/v1/namespace/kube-system/services/kube-dns/proxy
After reinstall I have checked current kubernetes config and it was as below
$ kubectl config view
In config you will still have
...
server: https://localhost:6445
...
Even after I deleted docker via Control Panel I still had C:\Users\%USERNAME%\.docker and C:\Users\%USERNAME%\.kube directories with config.
To back to default you need to delete Docker, remove manually .docker and .kube directories with configs and install docker.
Here I'm was using kubernetes for create the cluster manage with all my containers,Now i have some issues on that
- I'm using this command to install kubernetes:-
# dnf install docker cockpit cockpit-docker cockpit-kubernetes kubernetes etcd kubeadm -y
# docker version
# docker-ce-17.09.0.ce-1.fc26
This is my current status on kubernetes & docker.
This My current Status in the kubernetes cluster
When I Initialized Kubernetes Cluster have this kind of error
I did use below URL for deploy three node cluster.
https://blog.alexellis.io/kubernetes-in-10-minutes/
Note: if you want to start only single node cluster, then run taint command as per describe in above URL on master node so container can launch on master node also and if you want to run worker node separately then launch separate vm/vms and run command from start to till swapoff command then join vm to master.
I think you have missed a step in this link.
You seem to have not created a Pod network Add-on , create a local pod network such as flannel etc.
I have been trying to run tomcat container on port 5000 on cluster using kubernetes. But when i am using kubectl create -f tmocat_pod.yaml , it creates pod but docker ps does not give any output. Why is it so?
Ideally, when it is running a pod, it means it is running a container inside that pod and that container is defined in yaml file.
Why is that docker ps does not show any containers running?
I am following the below URLs:
http://containertutorials.com/get_started_kubernetes/k8s_example.html
https://blog.jetstack.io/blog/k8s-getting-started-part2/
How can I get it running and see tomcat running on browser on port 5000.
The docker containers should be running on the virtual machine. Since I only installed minikube on my local machine, I confirmed the following will bring what you want:
minikub ssh
...
docker ps
Just try the kubernetes equivalent of minikube ssh.
In Kubernetes, Docker contaienrs are run on Pods, and Pods are run on Nodes, and Nodes are run on your machine (minikube/GKE)
When you run kubectl create -f tmocat_pod.yaml you basically create a pod and it runs the docker container on that pod.
The node that holds this pod, is basically a virtual instance, if you could 'SSH' into that node, docker ps would work.
What you need is:
kubectl get pods <-- It is like docker ps, it shows you all the pods (think of it as docker containers) running
kubectl get nodes <-- view the host machines for your pods.
kubectl describe pods <pod-name> <-- view system logs for your pods.
kubectl logs <pod-name> <-- Will give you logs for the specific pod.
You can connect your Terminal with the docker server what is running inside your Node/VM.
With this command in your terminal: eval $(minikube docker-env)
This only configures your current terminal window.
illustration
may be you are not using docker as container runtime.
I faced the same issue, and i forgot that i switched to gVisor with runsc as handler.
cat /etc/default/kubelet
KUBELET_EXTRA_ARGS="--container-runtime remote --container-runtime-endpoint unix:///run/containerd/containerd.sock"
If so, you need to use runsc command instead of docker.
I'm not sure where you are running the docker ps command, but if you are trying to do that from your host machine and the k8s cluster is located elsewhere, i.e. your machine is not a node in the cluster, docker ps will not return anything since the containers are not tied to your docker host.
Assuming your pod is running, kubectl get pods will display all of your running pods. To check further details, you can use kubectl describe pod <yourpodname> to check the status of each container (in great detail). To get the pod names, you should be able to use tab-complete with the kubernetes cli. Also, if your pod contains multiple containers, you will need to give the container name as well, which you can use tab-complete for after you've selected your pod.
The output will look similar to:
kubectl describe pod comparison-api-dply-reborn-6ffb88b46b-s2mtx
Name: comparison-api-dply-reborn-6ffb88b46b-s2mtx
Namespace: default
Node: aks-nodepool1-99697518-0/10.240.0.5
Start Time: Fri, 20 Apr 2018 14:08:21 -0400
Labels: app=comparison-pod-reborn
pod-template-hash=2996446026
...
Status: Running
IP: *.*.*.*
Controlled By: ReplicaSet/comparison-api-dply-reborn-6ffb88b46b
Containers:
rabbit-mq:
...
Port: 5672/TCP
State: Running
...
If your containers and pods are already running, then you shouldn't need to troubleshoot them too much. To make them accessible from the Public Internet, take a look at Services (https://kubernetes.io/docs/concepts/services-networking/service/) to make your API's IP address fixed and easily reachable.
Have you tried a "docker ps -a" to see if the container is dead? If it is there you can see its logs with "docker logs " and maybe this gives you a hint.
If your pod is running successfully and if you are looking for the container on the node where the pod is scheduled the issue could be kubernetes is using a different container runtime.
Example
root#renjith-laptop:/home/renjith/raspbery-k8s# kubectl exec -it nginx-8586cf59-h92ct bash
root#nginx-8586cf59-h92ct:/# exit
exit
root#renjith-laptop:/home/renjith/raspbery-k8s# kubectl get po -o wide
NAME READY STATUS RESTARTS AGE IP NODE
nginx-8586cf59-h92ct 1/1 Running 0 47s 10.20.0.3 renjith-laptop
root#renjith-laptop:/home/renjith/raspbery-k8s# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root#renjith-laptop:/home/renjith/raspbery-k8s#
Here I am able exec to the pod, and I am in the same node where pod is scheduled, but docker ps doesn't show the container. In my case kubelet is using different container runtime, one of the argument to kubelet service is --container-runtime-endpoint=unix:///var/run/cri-containerd.sock
From Kubernetes documentation to get container images running on your system:
kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec.containers[*].image}" |\
tr -s '[[:space:]]' '\n' |\
sort |\
uniq -c
Then you get back something like:
2 registry.k8s.io/coredns/coredns:v1.9.3
1 registry.k8s.io/etcd:3.5.4-0
1 registry.k8s.io/kube-apiserver:v1.25.1
1 registry.k8s.io/kube-controller-manager:v1.25.1
3 registry.k8s.io/kube-proxy:v1.25.1
1 registry.k8s.io/kube-scheduler:v1.25.1