Skip to content

Commit

Permalink
[CE-363] Generate kubeconfig locally for ansible agent
Browse files Browse the repository at this point in the history
Generate kubeconfig locally to allow running kubectl from local
and copy kubeconfig to worker nodes in kubernetes cluster

Change-Id: I409e8b3c65d3ae3107990c5de6d95143410f6183
Signed-off-by: Surya <suryalnvs@gmail.com>
  • Loading branch information
suryalnvs committed May 11, 2018
1 parent 1135ee2 commit 0071edf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
8 changes: 8 additions & 0 deletions src/agent/ansible/roles/env_k8s/master/tasks/apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,11 @@
- kube-apiserver
- kube-controller-manager
- kube-scheduler

- name: Generate kubeconfig
template:
src: "{{ playbook_dir }}/../env_k8s/master/templates/kubeconfig.j2"
dest: "~/.kube/config"
mode: 0600
become: false
delegate_to: cloud
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ contexts:
current-context: k8s
kind: Config
preferences: {}
users: []
users: []
17 changes: 7 additions & 10 deletions src/agent/ansible/roles/env_k8s/worker/tasks/apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,14 @@
- kubelet
- kube-proxy

- name: Setup kubeconfig for each node
template:
src: "{{ playbook_dir }}/../env_k8s/worker/templates/kubeconfig.j2"
dest: "~/.kube/config"
mode: 0600

- name: Setup kubeconfig for each node
template:
src: "{{ playbook_dir }}/../env_k8s/worker/templates/kubeconfig.j2"
dest: "/etc/kubernetes/kubeconfig"
- name: Copy kubeconfig for each node
copy:
src: "~/.kube/config"
dest: "{{ item }}"
mode: 0600
with_items:
- ~/.kube/config
- /etc/kubernetes/kubeconfig

- name: Check kubelet version
command: "{{ fabricroot }}/bin/kubelet --version"
Expand Down

0 comments on commit 0071edf

Please sign in to comment.