Now Certified AWS Developer, SysOps, and Solutions Architect Associate 2018

April was a good month. Now I completed all three Amazon Web Services Cloud (AWS) associate certifications AWS Certified Solution Architect, AWS Certified Developer (2018), AWS Certified SysOPS Associate (2018).

json-server

A quick reminder about how to install json-server, that I use in many microservices workshops to quickly expose a REST API:

sudo yum install epel-release 
sudo yum install nodejs 
sudo yum install npm 
sudo npm install -g json-server

Emmy Roller Promotion CODE Gutschein SiQIj5SQ

Emmy Roller Scooter Promotion CODE / 15 Freiminuten

Gutschein SiQIj5SQ

Kubernetes Tipps, Tricks and Reads

Kubernetes Tidbits

Let’s face it. Most of us are not using the Kubernetes CLI every day. This posting is more a reminder for myself; I’d like to list some little helpers that help to improve your Kubernetes command-line skills:

Kubernetes Contexts

Show all available contexts (e.g. Minikube, GKE, Oracle Wercker):

$ kubectl config view --minify

YAML Output

Get the output of a deployment as more readable as YAML.

$ kubectl get deployment my-nginx -o yaml

Set custom namespace as default

Set default namespace, e.g. when working in a shared cluster.

$ kubectl config set-context $(kubectl config current-context) --namespace=XYZ
# Validate it
$ kubectl config view | grep namespace:

This one is again more a note to myself. Altogether I have spent way too much time to discover how to talk to containers running in Kubernetes from outside the Kubernetes cluster (Kubernetes for Docker, Oracle, GKE).

Run Pod via kubectl run then use kubectl expose deployment to expose via NodePort

  • deploy the container with kubectl run microg --image=fmunz/microg --port 5555
  • you will not see it as a service, e.g kubectl get services
  • expose the pod with kubectl expose deployment microg --type=NodePort. Note that other types are possible, see section below for deployment with a YAML file.
  • get the NodePort with kubectl describe service microg | grep NodePort
  • you will see the new service exposed as kubectl describe service microg

Deploy with Service YAML

For “kind” in the service YAML specify either (partly taken from K8s doc):

  • ClusterIP: Exposes the service on a cluster-internal IP. Choosing this value makes the service only reachable from within the cluster. This is the default ServiceType. To be able to talk to your service, start a Proxy server: kubectl proxy --port=8080

  • NodePort: Exposes the service on each Node’s IP at a static port (the NodePort). A ClusterIP service, to which the NodePort service will route, is automatically created. You’ll be able to contact the NodePort service, from outside the cluster, by requesting <nodeip>:<nodeport>. To find the NodePort, use the following command: kubectl describe service microg | grep NodePort

  • LoadBalancer: Exposes the service externally using a cloud provider’s load balancer. NodePort and ClusterIP services, to which the external load balancer will route, are automatically created.

.

Other resources

I will add more here for sure. These days I am using K8s a lot 🙂 Also check out the following resources:

To be continued

Kubernetes from the kubectl Command Line

Oracle Container Engine (OCE)

You most likely read the news that Oracle joined the CNCF and now offers a Kubernetes service named Oracle Container Engine. Basically you could use OCE nicely integrated with the CI/CD Wercker or alternatively from the command line.

OCE with Wercker

About using Kubernetes together with Wercker I will present at the CODE conference in NY city. So stay tuned for slides and possibly a recording.

OCE with standard kubectl CLI

OCE is a standard upstream Kubernetes. So with an existing kubectl client that is correctly pointing to your OCE instance you can try your first K8s steps from the CLI. So here is a quick primer.

The first thing to note is that you should set your namespace if you are using the OCE trial. The reason is, that there is shared cluster for trial and different users are assigned different namespaces. Don’t worry, if you are following the example with Wercker, given to the trial participants the namespace will be set correctly.

Set your namespace, replace fmunz with your namespace in the command below:

$ kubectl config set-context $(kubectl config current-context) --namespace=fmunz

Create a pod and scale it to 3 and :

$ kubectl run microg --image=fmunz/microg --port 5555
$ kubectl scale --replicas=3 deployment/microg

Note, that so far you only have a pod running, but no service. So your container will not be reachable from the outside. Now expose it as a service via the NodePort:

$ kubectl expose deployment microg --type=NodePort

Maybe most difficult question is how to access the service. You can find the NODE IPs of the pods using the wide flag when retrieving information about the pods:

$ kubectl get pods -o wide

NAME                                  READY     STATUS    RESTARTS   AGE       IP              NODE
microg-858154966-bfhg9                1/1       Running   0          2h        10.244.56.146   129.213.30.58
microg-858154966-k4v07                1/1       Running   0          2h        10.244.93.146   129.213.58.116
microg-858154966-p1tn9                1/1       Running   0          2h        10.244.99.40    129.213.36.50

Pick one of the NODE IPs, e.g. 129.213.30.58. Next, retrieve the NodePort that was created.

$ kubectl describe service microg | grep NodePort
Type:                     NodePort
NodePort:                 <unset>  32279/TCP

Now you can simply combine port and IP for the URL to access the service:

$ curl -s 129.213.30.58:32279

Which will show the following service response:

{"date":"Tuesday, 27-Feb-18 15:12:47 UTC","ip":"10.244.99.40","rel":"v1.0","cnt":174}

Hit it a couple more more times to investigate the load balancing.