Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f6d80b0

Browse files
authored
Merge pull request kubernetes-client#287 from dims/use-latest-localkube
Test with latest localkube version
2 parents 917ec63 + ebb23b7 commit f6d80b0

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

kubernetes/client/ws_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,18 @@ def __init__(self, configuration, url, headers):
4949
if url.startswith('wss://') and configuration.verify_ssl:
5050
ssl_opts = {
5151
'cert_reqs': ssl.CERT_REQUIRED,
52-
'keyfile': configuration.key_file,
53-
'certfile': configuration.cert_file,
5452
'ca_certs': configuration.ssl_ca_cert or certifi.where(),
5553
}
5654
if configuration.assert_hostname is not None:
5755
ssl_opts['check_hostname'] = configuration.assert_hostname
5856
else:
5957
ssl_opts = {'cert_reqs': ssl.CERT_NONE}
6058

59+
if configuration.cert_file:
60+
ssl_opts['certfile'] = configuration.cert_file
61+
if configuration.key_file:
62+
ssl_opts['keyfile'] = configuration.key_file
63+
6164
self.sock = WebSocket(sslopt=ssl_opts, skip_utf8_validation=False)
6265
self.sock.connect(url, header=header)
6366
self._connected = True

scripts/kube-init.sh

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,47 @@ sudo chmod +x kubectl
5555
sudo mv kubectl /usr/local/bin/
5656

5757
echo "Download localkube from minikube project"
58-
wget -O localkube "https://storage.googleapis.com/minikube/k8sReleases/v1.6.0-alpha.0/localkube-linux-amd64"
58+
wget -O localkube "https://storage.googleapis.com/minikube/k8sReleases/v1.7.0/localkube-linux-amd64"
5959
sudo chmod +x localkube
6060
sudo mv localkube /usr/local/bin/
6161

6262
echo "Starting localkube"
6363
sudo nohup localkube --logtostderr=true --enable-dns=false > localkube.log 2>&1 &
6464

6565
echo "Waiting for localkube to start..."
66-
if ! timeout 120 sh -c "while ! curl -ks https://127.0.0.1:8443/ >/dev/null; do sleep 1; done"; then
66+
if ! timeout 120 sh -c "while ! curl -ks http://127.0.0.1:8080/ >/dev/null; do sleep 1; done"; then
6767
sudo cat localkube.log
6868
die $LINENO "localkube did not start"
6969
fi
7070

71+
echo "Check certificate permissions"
72+
sudo chmod 644 /var/lib/localkube/certs/*
73+
sudo ls -altr /var/lib/localkube/certs/
74+
75+
echo "Set up .kube/config"
76+
mkdir ~/.kube
77+
cat <<EOF > ~/.kube/config
78+
apiVersion: v1
79+
clusters:
80+
- cluster:
81+
insecure-skip-tls-verify: true
82+
server: https://localhost:8443
83+
name: local
84+
contexts:
85+
- context:
86+
cluster: local
87+
user: myself
88+
name: local
89+
current-context: local
90+
kind: Config
91+
preferences: {}
92+
users:
93+
- name: myself
94+
user:
95+
client-certificate: /var/lib/localkube/certs/apiserver.crt
96+
client-key: /var/lib/localkube/certs/apiserver.key
97+
EOF
98+
7199
echo "Dump Kubernetes Objects..."
72100
kubectl get componentstatuses
73101
kubectl get configmaps

0 commit comments

Comments
 (0)