Guest User

Untitled

a guest
Jul 17th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. from kubernetes import config,client
  2.  
  3. configuration = kubernetes.client.Configuration()
  4. configuration.api_key['authorization'] = 'my decoded token from service account'
  5. configuration.api_key_prefix['authorization'] = 'Bearer'
  6. configuration.ssl_ca_cert = '/etc/secret-volume/ca-cert-chain'
  7. configuration.cert_file = 'cert.crt'
  8. configuration.key_file = '/etc/secret-volume/secret-key'
  9. configuration.verify_ssl = False
  10. configuration.assert_hostname = False
  11. v1 = kubernetes.client.CoreV1Api(kubernetes.client.ApiClient(configuration))
  12.  
  13. @app.route('/pods')
  14. def pods():
  15. ret = v1.list_pod_for_all_namespaces(watch=False)
  16. return jsonify(ret)
  17.  
  18. kubernetes.client.rest.ApiException: (404)
  19. Reason: NOT FOUND
  20. HTTP response headers: HTTPHeaderDict({'Content-Length': '233', 'Content-Type': 'text/html', 'Date': 'Tue, 17 Jul 2018 22:47:02 GMT', 'Server': 'Werkzeug/0.14.1 Python/3.5.5'})
  21. HTTP response body: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  22.  
  23. curl https://192.168.64.11:8443/api/v1/namespaces/my-namespace/pods --
  24. cert ~/.minikube/apiserver.crt --key ~/.minikube/apiserver.key --cacert
  25. ~/.minikube/ca.crt
Add Comment
Please, Sign In to add comment