Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
455 changes: 455 additions & 0 deletions docs/blogs/docker-graceful-shutdown.md

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions docs/devops/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# DevOps Assessment

How can I assess an organisation for what to do next.

## Questions

* To which extent can your development teams request/create an environment on their own, without going through lengthy approval processes?
* To which extent can your development teams use pre-configured/ template tool sets (e.g. Jenkins master jobs, master POM etc) which they can extend and/or modify to their needs?
* To which extent can your developments teams deploy to any environment (including production)? If not, what do they lack: knowledge or passwords to higher environments?
* Does your system of record provide you tractability from idea to production?
* How tightly coupled are your key delivery pipeline tools?
* Is it easy to replace them?
* Do you have different release management activities based on application blocks?
* Who is keeping it up-to-date?

## Maturity Model

## Resources

* https://www.devon.nl/continuous-delivery-at-enterprise-level-pitfall-1/
* https://www.devon.nl/continuous-delivery-at-enterprise-level-pitfall-2/
* https://devops-research.com/

## References


99 changes: 97 additions & 2 deletions docs/docker/graceful-shutdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func main() {
}
```

### Java plain
### Java plain (Docker Swarm)

This application is a Java 9 modular application, which can be found on github, [github.com/joostvdg](https://github.com/joostvdg/buming).

Expand Down Expand Up @@ -310,6 +310,100 @@ public class DockerApp {
}
```

### Java Plain (Kubernetes)

So far we've utilized the utilities from Docker itself in conjunction with it's native Docker Swarm orchestrator.

Unfortunately, when it comes to popularity [Kubernetes beats Swarm hands down](https://platform9.com/blog/kubernetes-docker-swarm-compared/).

So this isn't complete if it doesn't also do graceful shutdown in Kubernetes.

#### In Dockerfile

Our original file had to be changed, as Debian's Slim image doesn't actually contain the kill package.
And we need a kill package, as we cannot instruct Kubernetes to issue a specific SIGNAL.
Instead, we can issue a [PreStop exec command](https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/), which we can utilise to execute a [killall](https://packages.debian.org/wheezy/psmisc) java [-INT](https://www.tecmint.com/how-to-kill-a-process-in-linux/).

The command will be specified in the Kubernetes deployment definition below.

```dockerfile
FROM openjdk:9-jdk AS build

RUN mkdir -p /usr/src/mods/jars
RUN mkdir -p /usr/src/mods/compiled

COPY . /usr/src
WORKDIR /usr/src

RUN javac -Xlint:unchecked -d /usr/src/mods/compiled --module-source-path /usr/src/src $(find src -name "*.java")
RUN jar --create --file /usr/src/mods/jars/joostvdg.dui.logging.jar --module-version 1.0 -C /usr/src/mods/compiled/joostvdg.dui.logging .
RUN jar --create --file /usr/src/mods/jars/joostvdg.dui.api.jar --module-version 1.0 -C /usr/src/mods/compiled/joostvdg.dui.api .
RUN jar --create --file /usr/src/mods/jars/joostvdg.dui.client.jar --module-version 1.0 -C /usr/src/mods/compiled/joostvdg.dui.client .
RUN jar --create --file /usr/src/mods/jars/joostvdg.dui.server.jar --module-version 1.0 -e com.github.joostvdg.dui.server.cli.DockerApp\
-C /usr/src/mods/compiled/joostvdg.dui.server .

RUN rm -rf /usr/bin/dui-image
RUN jlink --module-path /usr/src/mods/jars/:/${JAVA_HOME}/jmods \
--add-modules joostvdg.dui.api \
--add-modules joostvdg.dui.logging \
--add-modules joostvdg.dui.server \
--add-modules joostvdg.dui.client \
--launcher dui=joostvdg.dui.server \
--output /usr/bin/dui-image

RUN ls -lath /usr/bin/dui-image
RUN ls -lath /usr/bin/dui-image
RUN /usr/bin/dui-image/bin/java --list-modules

FROM debian:stable-slim
LABEL authors="Joost van der Griendt <joostvdg@gmail.com>"
LABEL version="0.1.0"
LABEL description="Docker image for playing with java applications in a concurrent, parallel and distributed manor."
# Add Tini - it is already included: https://docs.docker.com/engine/reference/commandline/run/
ENV TINI_VERSION v0.16.1
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "-vv","-g", "--", "/usr/bin/dui/bin/dui"]
ENV DATE_CHANGED="20180120-1525"
RUN apt-get update && apt-get install --no-install-recommends -y psmisc=22.* && rm -rf /var/lib/apt/lists/*
COPY --from=build /usr/bin/dui-image/ /usr/bin/dui
RUN /usr/bin/dui/bin/java --list-modules
```

#### Kubernetes Deployment

So here we have the image's K8s [Deployment]() descriptor.

Including the Pod's [lifecycle]() ```preStop``` with a exec style command. You should know by now [why we prefer that](http://www.johnzaccone.io/entrypoint-vs-cmd-back-to-basics/).

```yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: dui-deployment
namespace: default
labels:
k8s-app: dui
spec:
replicas: 3
template:
metadata:
labels:
k8s-app: dui
spec:
containers:
- name: master
image: caladreas/buming
ports:
- name: http
containerPort: 7777
lifecycle:
preStop:
exec:
command: ["killall", "java" , "-INT"]
terminationGracePeriodSeconds: 60
```

### Java Spring Boot (1.x)

This example is for Spring Boot 1.x, in time we will have an example for 2.x.
Expand Down Expand Up @@ -656,4 +750,5 @@ buming_dui.0.pnoui2x6elrz@dui-2 | [Server-Ken Thompson] [INFO] [14:19:0
[^7]: [Grigorii Chudnov blog on Trapping Docker Signals](https://medium.com/@gchudnov/trapping-signals-in-docker-containers-7a57fdda7d86)
[^8]: [Andy Wilkinson (from pivotal) explaining Spring Boot shutdown hook for Tomcat](https://github.com/spring-projects/spring-boot/issues/4657#issuecomment-161354811)
[^9]: [Docker Swarm issue with multicast](https://github.com/docker/swarm/issues/1691)
[^10]: [Docker network library issue with multicast](https://github.com/docker/libnetwork/issues/552)
[^10]: [Docker network library issue with multicast](https://github.com/docker/libnetwork/issues/552)
[^11]: [Excellent article on JVM details inside Containers](https://jaxenter.com/nobody-puts-java-container-139373.html)
18 changes: 17 additions & 1 deletion docs/docker/kubernetes.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
# Kubernetes
# Kubernetes

## Kubernetes terminology



## Kubernetes model

## Resources

* https://github.com/weaveworks/scope
* https://github.com/hjacobs/kube-ops-view
* https://coreos.com/tectonic/docs/latest/tutorials/sandbox/install.html
* https://github.com/kubernetes/dashboard
* https://blog.alexellis.io/you-need-to-know-kubernetes-and-swarm/
* https://kubernetes.io/docs/reference/kubectl/cheatsheet/
* https://blog.heptio.com/core-kubernetes-jazz-improv-over-orchestration-a7903ea92ca
6 changes: 5 additions & 1 deletion docs/java/java9.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Java 9
# Java 9

* https://jaxenter.com/maven-on-java-9-things-you-need-to-know-140985.html
* https://blog.codefx.org/java/five-command-line-options-to-hack-the-java-9-module-system/
*
Empty file.
Empty file added docs/jenkins/java-gradle.md
Empty file.
Empty file added docs/jenkins/plugins.md
Empty file.
Loading