openshift.j2 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. if [ ! -d ~/.kube ]; then
  3. mkdir -m 0700 ~/.kube
  4. fi
  5. cmd=`basename $0`
  6. user=`id -u`
  7. group=`id -g`
  8. >&2 echo """
  9. ================================================================================
  10. ATTENTION: You are running ${cmd} via a wrapper around 'docker run {{ openshift.common.cli_image }}'.
  11. This wrapper is intended only to be used to bootstrap an environment. Please
  12. install client tools on another host once you have granted cluster-admin
  13. privileges to a user.
  14. {% if openshift.common.deployment_type in ['openshift-enterprise','atomic-enterprise'] %}
  15. See https://docs.openshift.com/enterprise/latest/cli_reference/get_started_cli.html
  16. {% else %}
  17. See https://docs.openshift.org/latest/cli_reference/get_started_cli.html
  18. {% endif %}
  19. =================================================================================
  20. """
  21. container="{{ openshift.common.service_type }}-master"
  22. is_running=false
  23. docker19_status=`docker inspect -f {% raw %}'{{ .State.Status }}'{% endraw %} $container`
  24. if [ "$docker19_status" == "<no value>" ]; then
  25. if docker inspect -f {% raw %}'{{ .State.Running }}'{% endraw %} $container | grep -i true > /dev/null; then
  26. is_running=true
  27. fi
  28. elif [ "$docker19_status" == "running" ]; then
  29. is_running=true
  30. fi
  31. if $is_running; then
  32. image=:`docker inspect -f {% raw %}'{{ .Image }}'{% endraw %} {{ openshift.common.service_type }}-master`
  33. else
  34. >&2 echo """
  35. Warning: {{ openshift.common.service_type }}-master service is not running. Using the latest image.
  36. """
  37. image=:latest
  38. fi
  39. docker run -i --privileged --net=host --user=${user}:${group} -v ~/.kube:/root/.kube -v /tmp:/tmp -v {{ openshift.common.config_base}}:{{ openshift.common.config_base }} -e KUBECONFIG=/root/.kube/config --entrypoint ${cmd} --rm {{ openshift.common.cli_image }}${image} "${@}"