Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
184 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
== Adapter | ||
|
||
* Prometheus adapter with `nc` for the random-generator service, transforming the log to a Prometheus related format | ||
IMPORTANT: The instructions have not been written/finished, but the resource file has been verified. Instructions will be added soon. | ||
|
||
|
||
=== More Information | ||
|
||
* https://www.youtube.com/watch?v=Ph3t8jIt894[Container patterns for modular distributed system design] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,27 @@ | ||
## Init Container | ||
== Init Container | ||
|
||
IMPORTANT: The instructions have not been written/finished, but the resource file has been verified. Instructions will be added soon. | ||
|
||
[source, bash] | ||
---- | ||
kubctl create -f pod.yml | ||
kubectl get pods -w | ||
NAME READY STATUS RESTARTS AGE | ||
www 0/1 Init:0/1 0 8s | ||
www 0/1 PodInitializing 0 10s | ||
www 1/1 Running 0 12s | ||
kubectl create -f service.yml | ||
port=$(kubectl get svc www -o jsonpath={.spec.ports[0].nodePort}) | ||
curl -s http://$(minikube ip):$port | ||
---- | ||
|
||
=== More Information | ||
|
||
* https://github.com/k8spatterns/examples/tree/master/structural/InitContainer[Init Container example] | ||
* https://kubernetes.io/docs/concepts/workloads/pods/init-containers/[Init Containers] | ||
* https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-initialization/#creating-a-pod-that-has-an-init-container[Configuring Pod Initialization] | ||
* http://blog.javascriptroom.com/2013/01/21/the-initializer-pattern/[The Initializer Pattern in JavaScript] | ||
* https://developer.apple.com/library/content/documentation/General/Conceptual/CocoaEncyclopedia/Initialization/Initialization.html[Object Initialization in Swift] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: www | ||
labels: | ||
app: www | ||
spec: | ||
initContainers: | ||
- name: download | ||
image: axeclbr/git | ||
# Clone an HTML page to be served | ||
command: | ||
- git | ||
- clone | ||
- https://github.com/mdn/beginner-html-site-scripted | ||
- /var/lib/data | ||
# Shared volume with main container | ||
volumeMounts: | ||
- mountPath: /var/lib/data | ||
name: source | ||
containers: | ||
# Simple static HTTP server for serving these pages | ||
- name: run | ||
image: docker.io/centos/httpd | ||
ports: | ||
- containerPort: 80 | ||
# Shared volume with main container | ||
volumeMounts: | ||
- mountPath: /var/www/html | ||
name: source | ||
volumes: | ||
- emptyDir: {} | ||
name: source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
== Init Container (random-genertor example) | ||
|
||
[source, bash] | ||
---- | ||
kubctl create -f deployment.yml | ||
k get pods -w | ||
NAME READY STATUS RESTARTS AGE | ||
random-generator-6c8f6bb79c-jc6nf 0/1 Init:0/1 0 4s | ||
random-generator-6c8f6bb79c-jc6nf 0/1 PodInitializing 0 61s | ||
random-generator-6c8f6bb79c-jc6nf 1/1 Running 0 62s | ||
kubectl create -f service.yml | ||
kubectl get service | ||
port=$(kubectl get svc random-generator -o jsonpath={.spec.ports[0].nodePort}) | ||
curl -s http://$(minikube ip):$port/logs | head -10 | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# DeploymentConfig for starting up the random-generator | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: random-generator | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: random-generator | ||
template: | ||
metadata: | ||
labels: | ||
app: random-generator | ||
spec: | ||
initContainers: | ||
# Same image as main container, but used for calling the batch CLI | ||
- image: k8spatterns/random-generator:1.0 | ||
name: init | ||
command: | ||
- java | ||
# Use / as classpath to pick up the class file | ||
- -classpath | ||
- / | ||
# Class running batch job | ||
- RandomRunner | ||
# 1. Arg: File to store data (on a PV) | ||
- /logs/random.log | ||
# 2. How many iterations | ||
- "100000" | ||
# Shared volume with main container. Use for initializing the batch file | ||
volumeMounts: | ||
- mountPath: /logs | ||
name: log-volume | ||
containers: | ||
# ------------------------------------------------ | ||
# Main container sharing the /logs dir with the init container | ||
- image: k8spatterns/random-generator:1.0 | ||
name: random-generator | ||
env: | ||
# The log file that we want to export | ||
- name: LOG_FILE | ||
value: /logs/random.log | ||
ports: | ||
# Application running on port 8080 | ||
- containerPort: 8080 | ||
protocol: TCP | ||
volumeMounts: | ||
- mountPath: /logs | ||
name: log-volume | ||
volumes: | ||
# New empty directory volume for sharing the log file between container | ||
- name: log-volume | ||
emptyDir: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: random-generator | ||
spec: | ||
selector: | ||
app: random-generator | ||
ports: | ||
- name: random | ||
port: 8080 | ||
protocol: TCP | ||
targetPort: 8080 | ||
type: NodePort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: www | ||
spec: | ||
selector: | ||
app: www | ||
ports: | ||
- name: http | ||
port: 8080 | ||
protocol: TCP | ||
targetPort: 80 | ||
type: NodePort |