• Stars
    star
    274
  • Rank 150,274 (Top 3 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 10 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Kubernetes Hands-on Workshop

Kubernetes for Java Developers

Create Resources

Pod

Using CLI

  1. Create pod: kubectl run wildfly --image=jboss/wildfly --port=8080

  2. Check status: kubectl get -w pods

    1. Show the pod name derived from the Deployment name

  3. Describe pod: kubectl describe pod <pod-name> or kubectl describe pod/<pod-name>

  4. Get logs: kubectl logs <pod-name>

    1. Use -f to tail logs

  5. Get deployments: kubectl get deployments

  6. Delete deployments: kubectl delete deployments/wildfly

  7. Get deployments: kubectl get deployments

  8. Get pods: kubectl get pods

Using Configuration File

  1. Create pod: kubectl create -f wildfly-pod.yaml

  2. Get pods: kubectl get pods

    1. Wide: kubectl get pods -o wide

    2. YAML: kubectl get pods -o yaml

    3. JSON: kubectl get pods -o json

  3. Describe pod: kubectl describe pod/wildfly-pod

  4. Delete pod: kubectl delete pod/wildfly-pod

  5. Get pods: kubectl get pods

Replication Controller

  1. Create RC: kubectl create -f wildfly-rc.yaml

  2. Get RC: kubectl get rc

  3. Get pods: kubectl get pods

    1. Show pod names

    2. Show image id downloaded on the second host

  4. Get pods created by RC: kubectl describe pods wildfly-rc

  5. Get pods with a specified label: kubectl get pods -l name=wildfly

  6. Delete RC: kubectl delete rc wildfly-rc

Service

  1. Create Service: kubectl create -f wildfly-service.yaml

  2. Get RC, Service and Pods: kubectl get rc,service,pods

  3. Describe service: kubectl describe service wildfly-service

  4. If Kubernetes is on cloud with LB

    1. Get the value of LoadBalancer Ingress, access the WildFly landing page at <IP>:8080

  5. Delete multiple resources: kubectl delete rc/wildfly-rc service/wildfly-service

Load Balancing

  1. ClusterIP: This is default, exposes service on cluster-internal IP.

    1. Create: kubectl create -f lb-clusterip.yaml

    2. Describe: kubectl get svc

      NAME              CLUSTER-IP    EXTERNAL-IP   PORT(S)    AGE
      kubernetes        100.64.0.1    <none>        443/TCP    48m
      wildfly-service   100.71.85.1   <none>        8080/TCP   13m

      Details: kubectl describe svc wildfly-service

      kubectl describe svc wildfly-service
      Name:			wildfly-service
      Namespace:		default
      Labels:			<none>
      Annotations:		<none>
      Selector:		app=wildfly-rc-pod
      Type:			ClusterIP
      IP:			100.71.85.1
      Port:			web	8080/TCP
      Endpoints:		100.96.1.4:8080,100.96.2.3:8080
      Session Affinity:	None
      Events:			<none>
    3. Access: Service is accessible only inside the cluster.

      1. Expose the service: kubectl expose service wildfly-service --port=8080 --target-port=8080 --name=web

      2. Start Kubernetes proxy: kubectl proxy

      3. Access the service: curl http://localhost:8001/api/v1/proxy/namespaces/default/services/web/index.html

    4. Delete:

      kubectl delete -f lb-clusterip.yaml
      kubectl delete svc/web
  2. NodePort: Expose service on each node of the cluster at a static port.

    1. Create: kubectl create -f lb-nodeport.yaml

    2. Describe: kubectl get svc

      NAME              CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
      kubernetes        100.64.0.1      <none>        443/TCP          2h
      wildfly-service   100.68.222.70   <nodes>       8080:32233/TCP   29m

      Details: kubectl describe svc wildfly-service

      Name:			wildfly-service
      Namespace:		default
      Labels:			<none>
      Annotations:		<none>
      Selector:		app=wildfly-rc-pod
      Type:			NodePort
      IP:			100.68.222.70
      Port:			web	8080/TCP
      NodePort:		web	32233/TCP
      Endpoints:		100.96.1.13:8080,100.96.2.12:8080
      Session Affinity:	None
      Events:			<none>
    3. Access: Service is accessible using <NodeIP>:<NodePort>. <NodePort> for us is 32233.

      1. Configure the worker node firewall to create a Custom TCP Rule to allow port 32233 accessible from Anywhere.

      2. Find IP address of the worker nodes using AWS Console.

      3. Service is accessible at <worker-node-ip>:32233.

    4. Delete: kubectl delete -f lb-nodeport.yaml

  3. LoadBalancer: Expose the service using a cloud provider’s load balancer.

    1. Create: kubectl create -f lb-loadbalancer.yaml

    2. Describe: kubectl get svc

      NAME              CLUSTER-IP       EXTERNAL-IP        PORT(S)          AGE
      kubernetes        100.64.0.1       <none>             443/TCP          2h
      wildfly-service   100.65.225.120   afa8056b14fc9...   8080:30229/TCP   4s

      Details:

      Name:			wildfly-service
      Namespace:		default
      Labels:			<none>
      Annotations:		<none>
      Selector:		app=wildfly-rc-pod
      Type:			LoadBalancer
      IP:			100.65.225.120
      LoadBalancer Ingress:	afa8056b14fc911e79b1906d8a9d4b8c-1413998286.us-west-2.elb.amazonaws.com
      Port:			web	8080/TCP
      NodePort:		web	30229/TCP
      Endpoints:		100.96.1.14:8080,100.96.2.13:8080
      Session Affinity:	None
      Events:
        FirstSeen	LastSeen	Count	From			SubObjectPath	Type		Reason			Message
        ---------	--------	-----	----			-------------	--------	------			-------
        11s		11s		1	service-controller			Normal		CreatingLoadBalancer	Creating load balancer
        8s		8s		1	service-controller			Normal		CreatedLoadBalancer	Created load balancer
    3. Access: Service is accessible at <LoadBalancer-Ingress>:8080. Wait for 3 mins for the load balancer to settle before accessing this URL. Firewall rules are created during the service creation.

    4. Delete: kubectl delete -f lb-loadbalancer.yaml

  4. ExternalName: Returns a CNAME record to an external service running outside the cluster. Allows for pods within the cluster to access the service outside the cluster. Redirection happens at DNS level, with no proxying or forwarding.

    1. Create

      1. Start a WildFly bitnami stack

      2. Get IP address of the provisioned host and replace the value in lb-external.yaml

      3. kubectl create -f lb-external.yaml

    2. Describe: kubectl get svc:

      NAME              CLUSTER-IP   EXTERNAL-IP                                         PORT(S)   AGE
      kubernetes        100.64.0.1   <none>                                              443/TCP   3h
      wildfly-service                ec2-34-210-79-105.us-west-2.compute.amazonaws.com   8080/TCP  2s

      Details: kubectl describe svc/wildfly-service

      Name:			wildfly-service
      Namespace:		default
      Labels:			<none>
      Annotations:		<none>
      Selector:		<none>
      Type:			ExternalName
      IP:
      External Name:		ec2-34-210-79-105.us-west-2.compute.amazonaws.com
      Port:			web	8080/TCP
      Endpoints:		<none>
      Session Affinity:	None
      Events:			<none>
    3. Access: This service is only accessible inside the cluster. kubectl expose only work for services with selectors.

    4. Delete: kubectl delete -f lb-external.yaml

Using Maven (Service + Replication Controller + Client Pod)

All the code is in maven directory:

  1. Create Couchbase service: kubectl create -f couchbase-service.yml

  2. Check status: kubectl get -w pods

  3. Run application: kubectl create -f bootiful-couchbase.yml

  4. Check status: kubectl get -w pods

    1. Show ContainerCreating

  5. Show all pods: kubectl get pods --show-all

  6. Check logs: kubectl logs -f <pod-name> to show the output Book{isbn=978-1-4919-1889-0, name=Minecraft Modding with Forge, cost=29.99}

  7. Delete all resources: kubectl delete -f couchbase-service.yml -f bootiful-couchbase.yml

Rolling Updates

Namespaces

  1. Create a new namespace: kubectl create -f dev-namespace.yaml

  2. Get namespaces: kubectl get namespace

  3. Create a new deployment in the namespace: kubectl --namespace=development run couchbase --image=arungupta/couchbase

  4. List deployments: kubectl get deployments

    1. No deployments shown

  5. List all resources in the namespace: kubectl get deployments --namespace=development

  6. List all resources in all namespaces: kubectl get deployments --all-namespaces

  7. Show pods in the namespaces: kubectl get pods --all-namespaces

Quota (broken)

  1. Create a constrained resource: kubectl create -f quota-wildfly.yaml

  2. Check for pods: kubectl get -w pods

  3. Broken: kubernetes/kubernetes#33621

Run-once/Batch Jobs

  1. Create a job: kubectl create -f runonce-job.yaml

  2. Check jobs: kubectl get jobs

  3. More details about job: kubectl describe jobs wait

  4. Check pods: kubectl get pods

  5. Show all completed pods: kubectl get pods --show-all

Daemon Set (work in progress)

  1. Create a daemon set: kubectl create -f prometheus-dameonset.yml .

Tips

  1. Create resources in all .json, .yaml and .yml files in dir: kubectl create -f ./dir

More Repositories

1

microservices

Java EE and Microservices
Java
630
star
2

docker-java

Docker for Java Developers
386
star
3

docker-images

Docker Images
Shell
250
star
4

docker-for-java

Docker for Java Developers
Shell
214
star
5

docker-java-sample

A simple Java sample that shows how to package Java application using Docker
Java
98
star
6

lil-kubernetes-for-java

Kubernetes for Java Developers - LinkedIn Learning Course
Java
98
star
7

docker-jenkins-pipeline

Devops for Java EE
Java
82
star
8

docker-scripts

Scripts to simplify Docker build, ship and run
Shell
67
star
9

oreilly-docker-book

Docker for Java developers book
Java
56
star
10

wildfly-samples

Samples for WildFly and related technologies
Java
55
star
11

serverless

Serverless samples
Java
46
star
12

container-service-discovery

Service Discovery in Container Orchestration Frameworks on AWS
JavaScript
45
star
13

lambda-rds-mysql

Shows how to use a Lambda function to store data in an RDS instance
Java
35
star
14

couchbase-kubernetes

Couchbase on Kubernetes
Shell
35
star
15

couchbase-javaee

Couchbase Java EE Application
Java
34
star
16

docker-java-multistage

Docker Java Multi-stage Builds
Java
34
star
17

docker-javaee

A simple Java EE application deployed using WildFly and accessing MySQL database
Java
31
star
18

docker-kubernetes-hello-world

Docker & Kubernetes Hello World
Java
30
star
19

chatbot

Build Your First Chatbot
Java
24
star
20

oreilly-kubernetes-book

Kubernetes for Java developers book
Java
23
star
21

devrel

Developer Advocates
21
star
22

kubernetes-maven

Fabric8 Maven plugin to deploy Java applications to Kubernetes
Java
17
star
23

spring-boot-prometheus

Prometheus-style metrics for a Spring Boot application in Kubernetes
Java
16
star
24

refcardz

Microservices refcardz
15
star
25

alexa-skill-java

Alexa Skill using Java
Java
15
star
26

docker-recipes

Docker Recipes
Shell
14
star
27

nuts-and-bolts-of-websocket

Nuts and Bolts of WebSocket
JavaScript
14
star
28

kubernetes-debug-tips

Kubernetes Debugging Tips
13
star
29

ecs-workshop

AWS EC2 Container Service Hands-on Workshop
12
star
30

kubernetes-chaos

Chaos Testing in Kubernetes
Smarty
11
star
31

lex-java

Amazon Lex Java API
Java
10
star
32

docker-java-ides

10
star
33

wildfly-deck

WildFly Deck
CSS
8
star
34

vault-kubernetes

Application secrets using Kubernetes and Vault
Java
8
star
35

wildfly-lab

Getting Started with WildFly Hands-on Lab
Shell
8
star
36

javaee6-sample

Java EE 6 Sample
Java
8
star
37

javaee7-continuous-delivery

Continuous Delivery with Java EE 7
Java
7
star
38

dynamodb-java-helloworld

Hello World for Amazon Web Services DynamoDB and Java
Java
7
star
39

docker-tutorial

Docker Tutorial
7
star
40

arun-gupta.github.io

Java
7
star
41

spigot-book

Minecraft Modding using Spigot
HTML
7
star
42

kubernetes-federated-cluster

Kubernetes Federated Cluster on AWS
5
star
43

couchbase-netbeans-plugin

NetBeans plugin for Couchbase
Java
5
star
44

wildfly-swarm-couchbase

WildFly Swarm Couchbase Sample
Java
5
star
45

javaee7-launch-demos

Demos used during Java EE 7 launch
Java
5
star
46

spring-hibernate-hsql

Spring Boot application using Hibernate with in-memory HSQL database
Java
5
star
47

grpc-hello-world-java

gRPC Hello World using Java
Java
4
star
48

kubernetes-chatbot

Create a Kubernetes cluster with a chatbot
Java
4
star
49

couchbase-spring

Couchbase Spring Application
Java
4
star
50

angular2-hello-world

Angular 2 Hello World
JavaScript
3
star
51

firecracker-firstlook

First Look at Firecracker
3
star
52

javaee7-docker-workflow

Continuous Deployment of Java EE using Docker and Jenkins
Java
3
star
53

twitter-api

Twitter API
Java
3
star
54

minecraft-forge-mods

Minecraft Mods using Forge
Java
3
star
55

sam-local-java

Serverless Application Model Java
Java
2
star
56

couchbase-xdcr-docker

Couchbase Cluster using Docker Swarm
Shell
2
star
57

jboss-samples

JBoss Samples
Java
2
star
58

docker-hello-world

Hello World Docker Image
JavaScript
2
star
59

vagrant-images

Vagrant Images
Ruby
2
star
60

tweet-analysis

Analyze Twitter Feed using N1QL
Java
2
star
61

todolist

TODO list created at San Francisco JUG
2
star
62

couchbase-amazon

Couchbase on Amazon
Shell
2
star
63

devops-javaee

2
star
64

books

Books authored by Arun Gupta
1
star
65

running

All my running adventures
1
star
66

environment-soarerwind-production

Makefile
1
star
67

serverless-couchbase

Java
1
star
68

kaazing-openshift-cartridge

Kaazing JMS Gateway OpenShift Cartridge
Shell
1
star
69

jdk-module-example

JDK Module Example
Java
1
star
70

sam-local-java-star

GitHub repository for AWS CodeStar Java Spring web service sam-local-java-.
Java
1
star
71

forge-plugins

Minecraft Forge Plugins
Java
1
star
72

javaee6-hol

Java EE 6 Hands-on Lab
Shell
1
star
73

dcos-java-database

Access a database from a Java application deployed in DC/OS
1
star
74

stateful-docker-containers

Stateful Docker Containers
1
star
75

spigot-archetype

Archetype to create a Bukkit plugin (used for Minecraft modding)
Java
1
star
76

couchbase-dcos

Couchbase Cluster using Apache Mesos or DC/OS
1
star
77

milestogo

Community Run
1
star
78

activemq-openshift-cartridge

ActiveMQ OpenShift Cartridge
Shell
1
star