Skip to content

Instantly share code, notes, and snippets.

@nicusX
Last active August 11, 2016 20:54
Show Gist options
  • Save nicusX/1b92aa354e054ed566f3b9118a536c82 to your computer and use it in GitHub Desktop.
Save nicusX/1b92aa354e054ed566f3b9118a536c82 to your computer and use it in GitHub Desktop.
# Expects `kubernetes_api_endpoint` as `--extra-vars "kubernetes_api_endpoint=xxxx"`
- hosts: 127.0.0.1
connection: local
tasks:
- name: Set kubectl endpoint
shell: "kubectl config set-cluster {{ cluster_name }} --certificate-authority={{ playbook_dir }}/../cert/ca.pem --embed-certs=true --server=https://{{ kubernetes_api_endpoint }}:6443"
- name: Set kubectl credentials
shell: "kubectl config set-credentials {{ user }} --token {{ token }}"
- name: Set kubectl default context
shell: "kubectl config set-context default-context --cluster={{ cluster_name }} --user={{ user }}"
- name: Switch kubectl to default context
shell: "kubectl config use-context default-context"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment