Privileged containers provisioning by Kubernetes in Ubuntu

来源:互联网 发布:李健 知乎 编辑:程序博客网 时间:2024/06/05 01:17

I followed theofficial guide to install and setup Kubernetes 1.0-release on Ubuntu. Here is the way to provision a privileged container.

  1. Switch to the Ubuntu directory
    root@master: cd $KUBERNETES_HOME/cluster/ubuntu
  2. Modify a file under Ubuntu directory
    vim util.sh
  3. Find two functions as following
    create-kube-apiserver-optscreate-kubelet-opts
  4. The functions above generate the options for kube-apiserver and kubelet, which apply the options while they are starting.
  5. Add a privileged flag in both of functions
    function create-kubelet-opts(){  cat <<EOF > ~/kube/default/kubeletKUBELET_OPTS="--address=0.0.0.0 \--port=10250 \--hostname_override=$1 \--api_servers=http://$2:8080 \--logtostderr=true \--cluster_dns=$3 \--cluster_domain=$4 \--allow-privileged=true"EOF}
    and
    function create-kube-apiserver-opts(){  cat <<EOF > ~/kube/default/kube-apiserverKUBE_APISERVER_OPTS="--address=0.0.0.0 \--port=8080 \--etcd_servers=http://127.0.0.1:4001 \--logtostderr=true \--service-cluster-ip-range=${1} \--admission_control=${2} \--service_account_key_file=/tmp/kube-serviceaccount.key \--allow-privileged=true \--service_account_lookup=false "EOF}
  6. Then restart all the Kubernetes by executing following commands
    root@master: cd $KUBERNETES_HOME/clusterroot@master: KUBERNETES_PROVIDER=ubuntu ./kube-down.shroot@master: KUBERNETES_PROVIDER=ubuntu ./kube-up.sh
  7. Write a template of replication controller as following
  8. Create the replication controller and then the Pods would be launched
0 0