Created
February 19, 2018 21:29
-
-
Save sdodson/d584c7659b92d4350b8a7baee24d26ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import subprocess | |
| system_hostname = subprocess.Popen("hostname -f", shell=True, stdout=subprocess.PIPE).stdout.read().strip() | |
| port = '443' | |
| cluster_hostname = subprocess.Popen("grep masterURL /etc/origin/master/master-config.yaml | awk '{ print $2 }' | cut -d/ -f3 | cut -d: -f1", shell=True, stdout=subprocess.PIPE).stdout.read().strip() | |
| print "oc config set-cluster --certificate-authority=/etc/origin/master/ca.crt --embed-certs=true --server=https://{0}:{1} {2}:{1} --config=/etc/origin/master/openshift-master.kubeconfig".format(system_hostname, port, system_hostname.replace('.', '-')) | |
| print "oc config set-context --cluster={0}:{1} --namespace=default --user=system:openshift-master/{2}:{1} default/{0}:{1}/system:openshift-master --config=/etc/origin/master/openshift-master.kubeconfig".format(system_hostname.replace('.', '-'), port, cluster_hostname.replace('.', '-')) | |
| print "oc config use-context default/{0}:{1}/system:openshift-master --config=/etc/origin/master/openshift-master.kubeconfig".format(system_hostname.replace('.', '-'), port) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment