Creating a cluster and retrieving its IP

You know the drill. Create a new cluster or reuse the one you dedicated to the exercises.

First, we'll go to the local copy of the vfarcic/k8s-specs repository and make sure that we have the latest revision. Who knows? I might have changed something since you read the last chapter.

All the commands from this chapter are available in the 05-chart-museum.sh (https://gist.github.com/vfarcic/e0657623045b43259fe258a146f05e1a) Gist.
 1  cd k8s-specs
2 3 git pull

The requirements for the cluster are now slightly different. We'll need Helm server (tiller). On top of that, if you are a minishift user, you'll need a cluster with 4 GB RAM.

For your convenience, the new Gists and the specs are available.

Besides creating a cluster, we'll need an IP through which we can access it. The instructions that follow differ from one Kubernetes flavor to another. Please make sure you execute those matching your cluster.

If your cluster is running in AWS and if it was created with kops, we'll retrieve the IP by digging the hostname of the Elastic Load Balancer (ELB). Please execute the commands that follow.

 1  LB_HOST=$(kubectl -n kube-ingress 
 2      get svc ingress-nginx 
 3      -o jsonpath="{.status.loadBalancer.ingress[0].hostname}")
 4
 5  LB_IP="$(dig +short $LB_HOST 
 6      | tail -n 1)"

If your cluster is running in AWS and if it was created as EKS, we'll retrieve the IP by digging the hostname of the ELB. Please execute the commands that follow.

 1  LB_HOST=$(kubectl -n ingress-nginx 
 2      get svc ingress-nginx 
 3      -o jsonpath="{.status.loadBalancer.ingress[0].hostname}")
 4
 5  LB_IP="$(dig +short $LB_HOST 
 6      | tail -n 1)"

If you're using Docker for Mac or Windows, the cluster is accessible through localhost. Since we need an IP, we'll use 127.0.0.1 instead. Please execute the command that follows.

 1  LB_IP="127.0.0.1"

Minikube users can retrieve the IP through minikube ip. If you are one of them, please execute the command that follows.

 1  LB_IP=$(minikube ip)

Retrieving IP from minishift is similar to minikube. If that's your Kubernetes flavor, please execute the command that follows.

 1  LB_IP=$(minishift ip)

Finally, if you are using GKE, the IP we're looking for is available through the ingress-nginx service. Please execute the command that follows.

 1  LB_IP=$(kubectl -n ingress-nginx 
 2      get svc ingress-nginx 
 3      -o jsonpath="{.status.loadBalancer.ingress[0].ip}")

No matter how you retrieved the IP of your cluster, we'll validate it by echoing the LB_IP variable.

 1  echo $LB_IP

The output will differ from one case to another. In my case, it is 52.15.140.221.

There's only one more thing left before we jump into Chart repositories. We'll merge your fork of the go-demo-3 code repository with the origin and thus ensure that you are up-to-date with changes I might have made in the meantime.

First, we'll move into the fork's directory.

 1  cd ../go-demo-3

To be on the safe side, we'll push the changes you might have made in the previous chapter, and then we'll sync your fork with the upstream repository. That way, we'll guarantee that you have all the changes I might have made.

You probably already know how to push your changes and how to sync with the upstream repository. In case you don't, the commands are as follows.

 1  git add .
2 3 git commit -m 4 "Packaging Kubernetes Applications chapter"
5 6 git push
7 8 git remote add upstream 9 https://github.com/vfarcic/go-demo-3.git
10 11 git fetch upstream
12 13 git checkout master
14 15 git merge upstream/master

We pushed the changes we made in the previous chapter, we fetched the upstream repository vfarcic/go-demo-3, and we merged the latest code from it. The only thing left is to go back to the k8s-specs directory.

 1  cd ../k8s-specs

Now we are ready to explore Helm repositories with ChartMuseum.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.161.116