I start to learn kubernetes. I follow a tutorial but I can't reproduce the step. I just install the kubectl and minikube, start minikube with docker as driver and run a pod.
filip@filip-pc:~/Desktop$ kubectl get pods
NAME READY STATUS RESTARTS AGE
my-apache 1/1 Running 0 5h7m
my-nging 1/1 Running 0 4h59m
filip@filip-pc:~/Desktop$ kubectl scale --replicas=2 my-apache
error: the server doesn't have a resource type "my-apache"
filip@filip-pc:~/Desktop$ kubectl cluster-info
Kubernetes master is running at https://172.17.0.3:8443
KubeDNS is running at https://172.17.0.3:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
I can se a pod but I can't manage it. if I follow the link https://172.17.0.3:8443 I get an error
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {
},
"status": "Failure",
"message": "forbidden: User \"system:anonymous\" cannot get path \"/\"",
"reason": "Forbidden",
"details": {
},
"code": 403
}
I do a short research on this error but the solutions that I found don't work for me. As I mention I am new to kubernetes but I understant that is a privilege issue but the user that I use have rights
filip@filip-pc:~/Desktop$ kubectl auth can-i create deployments --namespace dev
yes
filip@filip-pc:~/Desktop$ kubectl auth can-i create deployments --namespace prod
yes
Don't know which tutorial you are following and not sure how you created the pod but if it worked for them and it doesn't work for you then the issue is probably in that you are running newer version of kubernetes.
Using kubectl run ...
used to create pod as well as replication controller. Nowadays (since 1.18) it only creates a single pod. You need either replication controller (deprecated), or relicaset or deployment in order to scale it. You can't scale a single pod (pod resource doesn't have a concept of replicas that you might scale - increase/decrease).
You can replace the old run command with
kubectl create deployment myapache --image=httpd
and the scale it with
kubectl scale deployment myapache --replicas=2
It is not exactly the same as using the old run command but it is close.