-
Notifications
You must be signed in to change notification settings - Fork 10
/
remote-access-minikube.yaml
50 lines (43 loc) · 1.56 KB
/
remote-access-minikube.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
- name: Provide information for remote access of Minikube
hosts: all
gather_facts: false
vars:
local_kube_config_name: "minikube_server.kubeconfig"
local_kube_config_location: "minikube_server.kubeconfig"
remote_kube_config_location: "{{ dir_home }}/.kube/config"
remote_temp_file_location: "/tmp/minikube_config"
local_location: "./"
protocol: "http"
tasks:
- name: "Copy kubeconfig to {{ remote_temp_file_location }}"
copy:
src: "{{ remote_kube_config_location }}"
dest: "{{ remote_temp_file_location }}"
mode: 0644
remote_src: true
- name: "Edit kubeconfig file to change IP to '{{ protocol }}://{{ ip }}:{{ api_server_forwarded_port }}'"
become: true
replace:
path: "{{ remote_temp_file_location }}"
regexp: 'https.*'
replace: "{{ protocol }}://{{ ip }}:{{ api_server_forwarded_port }}"
- name: "Copy {{ remote_temp_file_location }} to current directory"
fetch:
src: "{{ remote_temp_file_location }}"
dest: "{{ local_kube_config_location }}"
flat: true
mode: 0644
- name: "Delete {{ remote_temp_file_location }}"
file:
path: "{{ remote_temp_file_location }}"
state: absent
- include_tasks: tasks-allow-ports.yaml
vars:
ports:
- "{{ api_server_forwarded_port }}"
- debug:
msg: >
Minikube is accessible at {{ ip }}:{{ api_server_forwarded_port }},
please use the kubeconfig from '{{ local_kube_config_location }}' to
access it.