Skip to content

Building Kubernetes Minikube

aborkar-ibm edited this page Apr 9, 2019 · 35 revisions

Building Kubernetes Minikube

The instructions provided below specify the steps to build Minikube version v0.30.0 on Linux on IBM Z for following distributions:

  • RHEL (7.4, 7.5, 7.6)
  • SLES (12 SP4, 15)
  • Ubuntu (16.04, 18.04)

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.

  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writeable directory anywhere you'd like to place it.

Building Minikube

  1. Build using script

If you want to build Minikube using manual steps, go to STEP 2.

Use the following commands to build Minikube using the build script. Please make sure you have wget installed.

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/Minikube/build_minikube.sh

# Build Minikube
bash build_minikube.sh   [Provide -t option for executing build with tests]

If the build completes successfully, go to STEP 6. In case of error, check logs for more details or go to STEP 2 to follow manual build steps.

  1. Install the build dependencies

    • RHEL (7.4, 7.5, 7.6)
    sudo yum install tar wget gcc git make python golang
    • SLES (12 SP4, 15)
    sudo zypper install tar wget gcc git make python
    • Ubuntu (16.04, 18.04)
    sudo apt-get update
    sudo apt-get install tar wget gcc git make python golang-1.10
    export PATH=/usr/lib/go-1.10/bin:$PATH
    • Docker packages are provided for SLES, Ubuntu and RHEL(7.5 or higher) in their respective repositories. Instructions for installing Docker on RHEL(7.3) can be found here.You may use the same instructions for RHEL (7.4, 7.5, 7.6) as the binaries are expected to be compatible. More information about Docker CE can be found here.
  2. Install Go (SLES) - Instructions for building Go can be found here.

  3. Build the Minikube

    • Get Minikube source code

      export GOPATH=/<source_root>/
      git clone https://github.com/kubernetes/minikube.git $GOPATH/src/k8s.io/minikube
      cd $GOPATH/src/k8s.io/minikube
      git checkout v0.30.0
    • Modify the Makefile

      @@ -297,7 +305,7 @@
      
       .PHONY: storage-provisioner-image
       storage-provisioner-image: out/storage-provisioner
      -	docker build -t $(REGISTRY)/storage-provisioner:$(STORAGE_PROVISIONER_TAG) -f deploy/storage-provisioner/Dockerfile .
      +	docker build -t $(REGISTRY)/storage-provisioner-s390x:$(STORAGE_PROVISIONER_TAG) -f deploy/storage-provisioner/Dockerfile .
      
       .PHONY: push-storage-provisioner-image
       push-storage-provisioner-image: storage-provisioner-image
    • Modify deploy/addons/addon-manager.yaml

      @@ -25,7 +25,7 @@
         hostNetwork: true
         containers:
         - name: kube-addon-manager
      -    image: k8s.gcr.io/kube-addon-manager:v8.6
      +    image: k8s.gcr.io/kube-addon-manager-s390x:v8.6
      	 env:
      	 - name: KUBECONFIG
      	   value: /var/lib/minikube/kubeconfig        
    • Modify deploy/addons/dashboard/dashboard-dp.yaml

      @@ -37,7 +37,7 @@
      	 spec:
      	   containers:
      	   - name: kubernetes-dashboard
      -        image: k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.0
      +        image: k8s.gcr.io/kubernetes-dashboard-s390x:v1.10.0
      		 imagePullPolicy: IfNotPresent
      		 ports:
      		 - containerPort: 9090
    • Modify deploy/addons/heapster/heapster-rc.yaml

      @@ -37,7 +37,7 @@
      	 spec:
      	   containers:
      	   - name: heapster
      -        image: k8s.gcr.io/heapster-amd64:v1.5.3
      +        image: k8s.gcr.io/heapster-s390x:v1.5.3
      		 imagePullPolicy: IfNotPresent
      		 command:
      		 - /heapster
    • Modify deploy/addons/kube-dns/kube-dns-controller.yaml

      @@ -44,7 +44,7 @@
      		   optional: true
      	   containers:
      	   - name: kubedns
      -        image: k8s.gcr.io/k8s-dns-kube-dns-amd64:1.14.5
      +        image: k8s.gcr.io/k8s-dns-kube-dns-s390x:1.14.5
      		 imagePullPolicy: IfNotPresent
      		 resources:
      		   # TODO: Set memory limits when we've profiled the container for large
      @@ -96,7 +96,7 @@
      		 - name: kube-dns-config
      		   mountPath: /kube-dns-config
      	   - name: dnsmasq
      -        image: k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64:1.14.5
      +        image: k8s.gcr.io/k8s-dns-dnsmasq-nanny-s390x:1.14.5
      		 imagePullPolicy: IfNotPresent
      		 livenessProbe:
      		   httpGet:
      @@ -135,7 +135,7 @@
      		 - name: kube-dns-config
      		   mountPath: /etc/k8s/dns/dnsmasq-nanny
      	   - name: sidecar
      -        image: k8s.gcr.io/k8s-dns-sidecar-amd64:1.14.5
      +        image: k8s.gcr.io/k8s-dns-sidecar-s390x:1.14.5
      		 imagePullPolicy: IfNotPresent
      		 livenessProbe:
      		   httpGet:
    • Modify deploy/addons/storage-provisioner/storage-provisioner.yaml

      @@ -51,7 +51,7 @@
         hostNetwork: true
         containers:
         - name: storage-provisioner
      -    image: gcr.io/k8s-minikube/storage-provisioner:v1.8.1
      +    image: gcr.io/k8s-minikube/storage-provisioner-s390x:v1.8.1
      	 command: ["/storage-provisioner"]
      	 imagePullPolicy: IfNotPresent
      	 volumeMounts:
    • Modify pkg/minikube/constants/constants.go

      @@ -169,7 +169,7 @@
       )
      
       func GetKubernetesReleaseURL(binaryName, version string) string {
      -	return fmt.Sprintf("https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/amd64/%s", version, binaryName)
      +	return fmt.Sprintf("https://storage.googleapis.com/kubernetes-release/release/%s/bin/linux/s390x/%s", version, binaryName)
       }
      
       func GetKubernetesReleaseURLSha1(binaryName, version string) string {
      @@ -183,10 +183,10 @@
       func GetKubeadmCachedImages(kubernetesVersionStr string) []string {
      
      	var images = []string{
      -		"k8s.gcr.io/kube-proxy-amd64:" + kubernetesVersionStr,
      -		"k8s.gcr.io/kube-scheduler-amd64:" + kubernetesVersionStr,
      -		"k8s.gcr.io/kube-controller-manager-amd64:" + kubernetesVersionStr,
      -		"k8s.gcr.io/kube-apiserver-amd64:" + kubernetesVersionStr,
      +		"k8s.gcr.io/kube-proxy-s390x:" + kubernetesVersionStr,
      +		"k8s.gcr.io/kube-scheduler-s390x:" + kubernetesVersionStr,
      +		"k8s.gcr.io/kube-controller-manager-s390x:" + kubernetesVersionStr,
      +		"k8s.gcr.io/kube-apiserver-s390x:" + kubernetesVersionStr,
      	}
      
      	gt_v1_10 := semver.MustParseRange(">=1.11.0")
      @@ -201,11 +201,11 @@
      
      	if v1_10(kubernetesVersion) || gt_v1_10(kubernetesVersion) {
      		images = append(images, []string{
      -			"k8s.gcr.io/pause-amd64:3.1",
      -			"k8s.gcr.io/k8s-dns-kube-dns-amd64:1.14.8",
      -			"k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64:1.14.8",
      -			"k8s.gcr.io/k8s-dns-sidecar-amd64:1.14.8",
      -			"k8s.gcr.io/etcd-amd64:3.1.12",
      +			"k8s.gcr.io/pause-s390x:3.1",
      +			"k8s.gcr.io/k8s-dns-kube-dns-s390x:1.14.8",
      +			"k8s.gcr.io/k8s-dns-dnsmasq-nanny-s390x:1.14.8",
      +			"k8s.gcr.io/k8s-dns-sidecar-s390x:1.14.8",
      +			"k8s.gcr.io/etcd-s390x:3.1.12",
      		}...)
      
      	} else if v1_9(kubernetesVersion) {
      @@ -228,9 +228,9 @@
      	}
      
      	images = append(images, []string{
      -		"k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.0",
      -		"k8s.gcr.io/kube-addon-manager:v8.6",
      -		"gcr.io/k8s-minikube/storage-provisioner:v1.8.1",
      +		"k8s.gcr.io/kubernetes-dashboard-s390x:v1.10.0",
      +		"k8s.gcr.io/kube-addon-manager-s390x:v8.6",
      +		"gcr.io/k8s-minikube/storage-provisioner-s390x:v1.8.1",
      	}...)
      
      	return images        
    • Modify deploy/storage-provisioner/Dockerfile

      @@ -12,6 +12,6 @@
       # See the License for the specific language governing permissions and
       # limitations under the License.
      
      -FROM scratch
      +FROM ubuntu:16.04
       COPY out/storage-provisioner storage-provisioner
       CMD ["/storage-provisioner"]
    • Build the Minikube

      cd $GOPATH/src/k8s.io/minikube
      make out/minikube-linux-s390x
    • Add minikube to /usr/bin

       sudo cp ./out/minikube-linux-s390x /usr/bin/minikube
      

      Note:

      • The tab space should be used for alignment in Makefile
  4. Execute test suite

    cd $GOPATH/src/k8s.io/minikube
    make test

    Note:

    • If you are using go v1.11, ignore the Gofmt errors in files: cmd/minikube/cmd/config/config_test.go error as that doesn't affect functionality.(Reference)
  5. Test Minikube service

    cd $GOPATH/src/k8s.io/minikube
    make storage-provisioner-image
    curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/s390x/kubectl && chmod +x kubectl && sudo cp kubectl /usr/local/bin/ && rm kubectl
    
    export MINIKUBE_WANTUPDATENOTIFICATION=false
    export MINIKUBE_WANTREPORTERRORPROMPT=false
    export MINIKUBE_HOME=$HOME
    export CHANGE_MINIKUBE_NONE_USER=true
    mkdir $HOME/.kube
    touch $HOME/.kube/config
    export KUBECONFIG=$HOME/.kube/config
    sudo -E ./out/minikube-linux-s390x start --vm-driver=none

    Note:

    • Above command will bring the single kubernetes cluster. The cluster can be viewed using the following command:
    kubectl get pods --all-namespaces

    Output should look similar to this:

    NAMESPACE     NAME                                    READY   STATUS    RESTARTS   AGE
    kube-system   coredns-c4cffd6dc-h7z68                 1/1     Running   0          1m
    kube-system   etcd-minikube                           1/1     Running   0          39s
    kube-system   kube-addon-manager-minikube             1/1     Running   0          30s
    kube-system   kube-apiserver-minikube                 1/1     Running   0          18s
    kube-system   kube-controller-manager-minikube        1/1     Running   0          20s
    kube-system   kube-dns-74b5f7bd8c-d6rpt               3/3     Running   0          1m
    kube-system   kube-proxy-bz7jp                        1/1     Running   0          1m
    kube-system   kube-scheduler-minikube                 1/1     Running   0          39s
    kube-system   kubernetes-dashboard-787985b498-ltf5z   1/1     Running   0          1m
    kube-system   storage-provisioner                     1/1     Running   1          1m
    

References:

https://github.com/kubernetes/minikube.git

Clone this wiki locally