Can we point kubernetes to another cluster

9/7/2018

I have asked myself this question and invested time researching it. Running out of time. Can someone point me in the right direction? I have created a kubernetes cluster on minikube, with its Ingress, Services and Deployments. There is a whole configuration of services in there. Can, now, I point this kubectl command to another provider like VMWareFusion, AWS , Azure, not to forget Google Cloud. I know about kops. My understanding is that although this is the design goal of kops but presently it only supports AWS.

-- Tauqir Chaudhry
cloud
kubectl
kubernetes

2 Answers

9/7/2018

Yes, you can use different clusters via the context. List them using kubectl config get-contexts and switch between them using kubectl config use-context.

-- Michael Hausenblas
Source: StackOverflow

9/7/2018

I would like to suggest you couple of things the way i worked out with kubernetes, From my local system to production my environment remains consistent.

I use kubeadm to create a kubernetes cluster on my local machine. And I maintain all my kubernetes resources like Services, Pods, Deployment etc.. in a yaml as my deployment files.

  • All my services and pods are saved in a yaml file e.g. counter.yaml

    kind: Deployment apiVersion: extensions/v1beta1 metadata: name: deployment-counter namespace: default labels: module: log-counter spec: replicas: 1 selector: matchLabels: module: log-counter template: metadata: labels: module: log-counter spec: containers: - name: container-counter image: busybox command: - "/bin/sh" - "-c" - 'i=0; while true; do echo "$i: $(date)"; i=$((i+1)); sleep 1; done' imagePullPolicy: Always restartPolicy: Always terminationGracePeriodSeconds: 30 tolerations: - key: ud_application operator: Equal value: docxtract effect: NoSchedule - key: ud_module operator: Exists effect: NoSchedule strategy: type: RollingUpdate

On my local kubernetes cluster provisioned by kubeadm I deploy it as follow

kubectl apply -f counter.yaml

And on Production i have a kubernetes cluster provisioned by kubeadm too and i deploy it the same way.
kubectl apply -f counter.yaml

PS:

kubeadm is a tool provided by kubernetes to provision a kubernetes cluster.

-- DevScript
Source: StackOverflow