error installing helm chart in kubernates - kubernetes

I am trying to install helm chart on kubernates cluster. When i try to initialize the helm using init command, it is throwing error as "error installing: the server could not find the requested resource"
provider.helm v2.14.3
provider.kubernetes v1.16
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.0", GitCommit:"2bd9643cee5b3b3a5ecbd3af49d09018f0773c77", GitTreeState:"clean", BuildDate:"2019-09-18T14:36:53Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.0", GitCommit:"2bd9643cee5b3b3a5ecbd3af49d09018f0773c77", GitTreeState:"clean", BuildDate:"2019-09-18T14:27:17Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
$ helm version
Client: &version.Version{SemVer:"v2.14.3", GitCommit:"0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085", GitTreeState:"clean"}
Error: could not find tiller
$ helm init
Creating /home/cloud_admin/.helm
Creating /home/cloud_admin/.helm/repository
Creating /home/cloud_admin/.helm/repository/cache
Creating /home/cloud_admin/.helm/repository/local
Creating /home/cloud_admin/.helm/plugins
Creating /home/cloud_admin/.helm/starters
Creating /home/cloud_admin/.helm/cache/archive
Creating /home/cloud_admin/.helm/repository/repositories.yaml
Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com
Adding local repo with URL: http://127.0.0.1:8879/charts
$HELM_HOME has been configured at /home/cloud_admin/.helm.
Error: error installing: the server could not find the requested resource
$ kubectl get node -n kube-system
NAME STATUS ROLES AGE VERSION
openamvmimsload0 Ready master 5h11m v1.16.0
openamvmimsload1 Ready <none> 5h1m v1.16.0
$ kubectl config get-clusters
NAME
kubernetes
$ kubectl cluster-info
Kubernetes master is running at https://172.16.128.40:6443
KubeDNS is running at https://172.16.128.40:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 5h15m

This seems to be a bug with Helm 2.14.3 (and previous) and Kubernetes 1.16 Helm init fails on Kubernetes 1.16.0 bug report on GitHub.
The ticket lists some workarounds - the simplest one is:
helm init --override spec.selector.matchLabels.'name'='tiller',spec.selector.matchLabels.'app'='helm' --output yaml | sed 's#apiVersion: extensions/v1beta1#apiVersion: apps/v1#' | kubectl apply -f -
or with RBAC enabled and tiller service account:
helm init --service-account tiller --override spec.selector.matchLabels.'name'='tiller',spec.selector.matchLabels.'app'='helm' --output yaml | sed 's#apiVersion: extensions/v1beta1#apiVersion: apps/v1#' | kubectl apply -f -

it will work if you use this command:
helm init --override spec.selector.matchLabels.'name'='tiller',spec.selector.matchLabels.'app'='helm' --output yaml | sed 's#apiVersion: extensions/v1beta1#apiVersion: apps/v1#' | kubectl apply -f -```

Related

K8s Error from server (NotFound): deployments.apps "nginx" not found

Problem
Coursera Google Cloud Fundamentals: Getting Started with Kubernetes Engine
has the instructions to run and expose the pod. The demo video shows it is working.
However, it causes the error in my execution. How to fix?
kubectl run nginx --image=nginx:1.10.0
kubectl expose deployment nginx --type LoadBalancer --port 80
---
Error from server (NotFound): deployments.apps "nginx" not found
Environment
GCP k8s.
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.1", GitCommit:"632ed300f2c34f6d6d15ca4cef3d3c7073412212", GitTreeState:"clean", BuildDate:"2021-08-19T15:45:37Z", GoVersion:"go1.16.7", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"20+", GitVersion:"v1.20.8-gke.2100", GitCommit:"4cd085fda961821985d176d25b67445c1efb6ba1", GitTreeState:"clean", BuildDate:"2021-07-16T09:22:57Z", GoVersion:"go1.15.13b5", Compiler:"gc", Platform:"linux/amd64"}
WARNING: version difference between client (1.22) and server (1.20) exceeds the supported minor version skew of +/-1
Cause
kubectl run does not create deployment.
'Error from server (NotFound): deployments.extensions "nginx" not found' when exposing NodePort #31
Did you create a pod with "kubectl run"? If yes, that doesn't create a deployment with (at least) kubectl v1.18.2, so instead use "kubectl create deployment nginx --image=nginx:1.10.0"
Fix
Create a deployment as in Creating and exploring an nginx deployment from a YAML or run kubectl create deployment ....
$ kubectl create deployment nginx --image=nginx:1.12.0
deployment.apps/nginx created
$ kubectl expose deployment nginx --type LoadBalancer --port 80
service/nginx exposed
$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.83.240.1 <none> 443/TCP 44m
nginx LoadBalancer 10.83.246.84 35.225.127.227 80:30825/TCP 60s

How to install Cassandra in minikube

I was wondering if there is a way to install a cassandra cluster locally in minikube. I found some solutions just to install it in cloud provisioners like GCP but I need to install in my dev environment.
I'm able to install cassandra using helm charts in minikube v1.9.2 running k8s v1.17.4 on Ubuntu 16.04 Xenial like this:
git clone git#github.com:helm/charts.git
cd charts
kubectl create ns cassandra
helm install cassandra --namespace "cassandra" incubator/cassandra
$ kubectl get pods,svc -n=cassandra
NAME READY STATUS RESTARTS AGE
pod/cassandra-0 1/1 Running 0 3m52s
pod/cassandra-1 0/1 Running 0 104s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/cassandra ClusterIP None <none> 7000/TCP,7001/TCP,7199/TCP,9042/TCP,9160/TCP 3m52s
## see status of cassandra cluster
$ kubectl exec -it --namespace cassandra cassandra-0 nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 172.18.0.6 89.13 KiB 256 65.4% 09486d44-43d6-47eb-b455-8856d566ac0a rack1
UN 172.18.0.4 74.93 KiB 256 67.5% d7c24d6a-0ba5-498f-a65c-4a858cba282e rack1
UN 172.18.0.5 74.92 KiB 256 67.1% 14c2eea0-efdf-444e-9e97-936d9710c2eb rack1
## my helm, minikube and k8s versions
$ helm version
version.BuildInfo{Version:"v3.0.2", GitCommit:"19e47ee3283ae98139d98460de796c1be1e3975f", GitTreeState:"clean", GoVersion:"go1.13.5"}
$ minikube version
minikube version: v1.9.2
commit: 93af9c1e43cab9618e301bc9fa720c63d5efa393
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.4", GitCommit:"8d8aa39598534325ad77120c120a22b3a990b5ea", GitTreeState:"clean", BuildDate:"2020-03-12T21:03:42Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.4", GitCommit:"8d8aa39598534325ad77120c120a22b3a990b5ea", GitTreeState:"clean", BuildDate:"2020-03-12T20:55:23Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"linux/amd64"}
This link has steps to create a StorageClass to persist data in cassandra.
This link has more information about cassandra helm charts and its configurations.

Kubernetes - unable to run echoserver on minikube

I am following this example
When I run the following command I get the error:
➜ kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.10
Error from server (NotFound): the server could not find the requested resource
I just installed fresh minikube, kubectl and the data is below:
Development/tools/k8s
➜ kubectl get nodes
NAME STATUS AGE
minikube Ready 2m
Development/tools/k8s
➜ kubectl get pods
No resources found.
Development/tools/k8s
➜ kubectl get rc --all-namespaces
No resources found.
Development/tools/k8s
➜ kubectl cluster-info
Kubernetes master is running at https://192.168.99.101:8443
KubeDNS is running at https://192.168.99.101:8443/api/v1/proxy/namespaces/kube-system/services/kube-dns
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
➜ kubectl version
Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.3", GitCommit:"029c3a408176b55c30846f0faedf56aae5992e9b", GitTreeState:"clean", BuildDate:"2017-02-15T06:40:50Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.3", GitCommit:"06ad960bfd03b39c8310aaf92d1e7c12ce618213", GitTreeState:"clean", BuildDate:"2020-02-11T18:07:13Z", GoVersion:"go1.13.6", Compiler:"gc", Platform:"linux/amd64"}
➜ minikube version
minikube version: v1.7.3
commit: 436667c819c324e35d7e839f8116b968a2d0a3ff
What am I doing wrong?
Your kubectl is version 1.5 which is very old. It’s trying to use an outdated format for the Deployment resource which no longer exists in the server.

unable to launch kubectl dashboard on Mac

I have deployed minikube on MacOS using the instructions here https://kubernetes.io/docs/tasks/tools/install-minikube/
The brew install was ok and the minikube status shows
$ minikube status
host: Running
kubelet: Running
apiserver: Running
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.102
I am able to interact with the cluster using kubectl
$kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.10 --port=8080
Viewing the pods is also ok
$kubectl get pod
NAME READY STATUS RESTARTS AGE
hello-minikube-856979d68c-glhsx 1/1 Running 0 18m
But when i try to launch the kubectl dashboard, i get 503 error
$minikube dashboard
Temporary Error: unexpected response code: 503
Temporary Error: unexpected response code: 503
The Dashboard service seems to present
$kubectl -n kube-system get svc -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 3h19m k8s-app=kube-dns
kubernetes-dashboard ClusterIP 10.109.210.119 <none> 80/TCP 119m app=kubernetes-dashboard
below is the kubectl version info
$kubectl version
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.2", GitCommit:"f6278300bebbb750328ac16ee6dd3aa7d3549568", GitTreeState:"clean", BuildDate:"2019-08-05T16:57:42Z", GoVersion:"go1.12.7", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.2", GitCommit:"f6278300bebbb750328ac16ee6dd3aa7d3549568", GitTreeState:"clean", BuildDate:"2019-08-05T09:15:22Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
Any pointers on what is missing ? How to get the dashboard working
Thanks
Praveen
Check kubectl cluster-info, you can find more here
kubectl -n kube-system port-forward svc/kubernetes-dashboard 8080:80
Your dashboard should be accessible on http://localhost:8080, keep in mind that the dashboard is deprecated so you can check octant.
Try $ minikube dashboard command. It will open a new tab in your default browser showing the minikube dashbord.
Finally able to solve this issue with instructions from GitHub issues
https://github.com/kubernetes/minikube/issues/4352
Basically, with these commands
minikube stop
minikube start --extra-config=apiserver.authorization-mode=RBAC
kubectl create clusterrolebinding add-on-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:default
minikube dashboard

Is it possible to install knative on docker for mac

I followed this guide and everything started running.
kubectl get pods --namespace=knative-serving -w
NAME READY STATUS RESTARTS AGE
activator-f98dc8dc8-r6qlg 0/2 PodInitializing 0 5m
autoscaler-7787cd648-4lwdg 2/2 Running 0 5m
controller-55f7988d59-d8zwd 1/1 Running 0 5m
webhook-5b844dfbd5-7bz84 1/1 Running 0 5m
activator-f98dc8dc8-r6qlg 2/2 Running 0 5m
After a few seconds, kubectl commands are failing with the following error.
kubectl get nodes
Unable to connect to the server: net/http: TLS handshake timeout
Is it possible to install knative on docker for mac kubernetes cluster?
My kubernetes version:
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.1", GitCommit:"b1b29978270dc22fecc592ac55d903350454310a", GitTreeState:"clean", BuildDate:"2018-07-18T11:37:06Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:05:37Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"
Knative provides a set of middleware components that are essential to build modern, source-centric, and container-based applications that can run anywhere: on premises, in the cloud, or even in a third-party data center. Knative components are built on Kubernetes and codify the best practices shared by successful real-world Kubernetes-based frameworks. It enables developers to focus just on writing interesting code, without worrying about the “boring but difficult” parts of building, deploying, and managing an application.
Back to your question.
It is possible to use Knative on Docker containers mananaged by Kubernetes on MacOS environment. You may try to install it
on Minikube.
Start minikube:
minikube start --memory=8192 --cpus=4 \ --kubernetes-version=v1.10.5
\ --vm-driver=hyperkit \ --bootstrapper=kubeadm \
--extra-config=controller-manager.cluster-signing-cert-file="/var/lib/localkube/certs/ca.crt"
\
--extra-config=controller-manager.cluster-signing-key-file="/var/lib/localkube/certs/ca.key"
\
--extra-config=apiserver.admission-control="LimitRanger,NamespaceExists,NamespaceLifecycle,ResourceQuota,ServiceAccount,DefaultStorageClass,MutatingAdmissionWebhook"
Install Istio with NodePort feature:
curl -L
https://raw.githubusercontent.com/knative/serving/v0.1.1/third_party/istio-0.8.0/istio.yaml
\ | sed 's/LoadBalancer/NodePort/' \ | kubectl apply -f -
kubectl label namespace default istio-injection=enabled
Monitor the Istio components until all of the components show a STATUS of Running or Completed:
kubectl get pods -n istio-system --watch
Install knative for resource limited environment:
curl -L
https://github.com/knative/serving/releases/download/v0.1.1/release-lite.yaml
\ | sed 's/LoadBalancer/NodePort/' \ | kubectl apply -f -
Monitor the Knative components until all of the components show a STATUS of Running:
kubectl get pods -n knative-serving --watch
Yes, it's absolutely possible to run Knative on Docker for Mac. I've assembled specific instructions in the upstream documentation repository.
Make sure you update Docker for Mac to be on one of the later versions. Knative meanwhile needs Kubernetes 1.12+.