Unable to switch from Minikube to AWS EKS on windows for Deployment - powershell

I have minikube on my local machine for testing deployment and I ran commands like
kubectl apply -f testingfile.yaml
and it worked fine. Now I want to perform the same on aws eks. I have followed all steps given in https://docs.aws.amazon.com/eks/latest/userguide/sample-deployment.html. Created a config file and added that to the path. Commands like eksctl get cluster are correctly listing the clusters from aws eks but now when I run
kubectl apply -f testingfile.yaml
I am getting the following statement
deployment.apps/testingfile unchanged which means it is still applying the command inside minikube and not on aws eks. I have also deleted path variables related to minikube from environment variables but I am still unable to switch to aws eks for applying. I would like to deploy this on aws eks. Let me know what I am missing here

Checking your existing cluster contexts
There will multiple contexts one for Minikube and One for EKS
kubectl config get-contexs
change context to EKS if your config is set it will be there
kubectl config use-context <Name of context>
this way you can get changed to another clusters.

Related

How to use kubectl command for kubernetes implemented in rancher run with docker?

I built a rancher using docker on server 1.
I created and added a kubernetes cluster on server 2, and I wanted to access the kubernetes with the kubectl command on server 2 local, but localhost:8080 error is displayed.
How can I apply kubectl command to kubernetes configured with docker rancher locally?
I fixed that issue modifying the kube config file.
The kubeconfig file can be checked by entering the rancher
The file to be modified is ~/.kube/config

ArgoCD deployment to eks and aks

Is there any way that ArgoCD deploy to AKS and EKS cluster simultaneously. I don't see anything setting in ArgoCD to connect to another cluster. My aim is that I want ArgoCD to deploy in both AKS and EKS. As of now since ArgoCD is deployed to EKS so by default its picking it up but I want to connect ArgoCD with AKS as well. If there is a way please tell me.
Yes, you can deploy to multiple clusters or external clusters using the Argo CD.
please check this out : https://blog.doit-intl.com/automating-kubernetes-multi-cluster-config-with-argo-cd-5ac5e371ef01
if your argo CD is running local on same host
you can check the existing clusters using the
kubectl config get-contexts
and using cluster context Name you can add the context to the Argo CD via agro cli
argocd cluster add RESPECTIVE-CONTEXT name
https://argoproj.github.io/argo-cd/user-guide/commands/argocd_cluster_add/
readmore at : https://itnext.io/argocd-setup-external-clusters-by-name-d3d58a53acb0

How to access local kubernete cluster

I have deployed 1 master and 3 nodes on VM's.
I can run successfully "kubectl" command on the server's SSH CLI. I can deploy pods, all fine.
But I couldn't find how can I run "kubectl" command from my local and manage the K8S cluster? How can I do that?
Thanks!
You might have a kubeconfig file somewhere on the VMs. You can copy this one to your local device under $HOME/.kube/config, so kubectl knows how to access the cluster.
For more information, see the kubernetes documentation.
From your local machine run:
kubectl config get-contexts
Then run the below (replace cluster-name with the cluster name you want to communicate with):
kubectl config use-context cluster-name
If the cluster name you want to communicate with is not listed, it means you haven't got to context file to the cluster.

How to deploy application to a different cluster within same google cloud project?

I have one google cloud project, but have 2 different kubernetes clusters. Each of these clusters have one node each.
I would like to deploy an application to a specific kubernetes cluster. The deployment defaults to the other cluster. How can I specify which kubernetes cluster to deploy my app to?
See the cluster with which kubectl is currently communicating:
kubectl config current-context
Set the cluster with which you want kubectl to communicate:
kubectl config use-context my-cluster-name
See official docs here for more details

Update deployment fails when same name exists in separate namespaces

I've used the following command to update the image run in a deployment:
kubectl --cluster websites --namespace production set image
deployment/mobile-web mobile-web=eu.gcr.io/websites/mobile-web:0.23
This worked well until I created a staging namespace mirroring the production environment. In other words the deployment mobile-web exists both in the production and staging namespace. Now I get the error:
Error from server: the server could not find the requested resource
(get deployments.extensions mobile-web)
What am I missing here? Or is the only way to update using a yaml- or JSON-file, which means a bit more work on the CI/CD pipeline? I've tried setting the namespace with:
kubectl config set-context production --namespace=production --cluster=websites
but to no avail.
The solution for my concern was to kill the current proxy and get new credentials and start the proxy again:
gcloud container clusters get-credentials websites
kubectl proxy --port=8080
Now either commands work as expected:
kubectl get deployment mobile-web --namespace=production
kubectl get deployment mobile-web --namespace=staging
However it doesn't explain why it stopped working in the first place.