Skip to content

Commit

Permalink
add fact
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennecoutaud committed Apr 20, 2018
1 parent 9461592 commit cd42c5d
Show file tree
Hide file tree
Showing 18 changed files with 355 additions and 1 deletion.
11 changes: 11 additions & 0 deletions factor10/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

FROM golang:1.10
COPY . /go/app/
WORKDIR /go/app/
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s" -o app

FROM scratch
COPY --from=0 /go/app /
LABEL app.language=golang app.name=kanary-operator
EXPOSE 8080
ENTRYPOINT ["/app"]
23 changes: 23 additions & 0 deletions factor10/app/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"fmt"
"log"
"net/http"
"math/rand"
"time"
)

func main() {

s1 := rand.NewSource(time.Now().UnixNano())
r1 := rand.New(s1)
randValue := r1.Intn(100)

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "%d\n", randValue)
})

log.Fatal(http.ListenAndServe(":8080", nil))

}
34 changes: 34 additions & 0 deletions factor10/rs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: stateful-app
namespace: factor10
spec:
replicas: 1
selector:
matchLabels:
app: stateful
template:
metadata:
labels:
app: stateful
spec:
containers:
- name: stateful
image: etiennecoutaud/statefull-app:0.1
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: myapp
namespace: factor10
spec:
type: ClusterIP
selector:
app: stateful
ports:
- protocol: TCP
port: 8080
10 changes: 10 additions & 0 deletions factor11/pvc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mystorage
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
26 changes: 26 additions & 0 deletions factor11/rs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: nginx
namespace: factor11
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
volumes:
- name: persistent-storage
persistentVolumeClaim:
claimName: mystorage
containers:
- name: nginx
image: nginx:alpine
volumeMounts:
- name: persistent-storage
mountPath: /data
2 changes: 1 addition & 1 deletion factor2/rs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ReplicaSet
metadata:
name: simple-nginx
spec:
replicas: 3
replicas: 1
selector:
matchLabels:
app: nginx
Expand Down
27 changes: 27 additions & 0 deletions factor4/simple-clusterIP.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
apiVersion: v1
kind: Service
metadata:
name: nginx-clusterip
namespace: factor4
spec:
type: ClusterIP
selector:
app: nginx
type: clusterIP
ports:
- protocol: TCP
port: 80
---
apiVersion: v1
kind: Pod
metadata:
name: nginx-clusterip
namespace: factor4
labels:
app: nginx
type: clusterIP
spec:
containers:
- name: nginx
image: nginx:alpine
27 changes: 27 additions & 0 deletions factor4/simple-lb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
apiVersion: v1
kind: Service
metadata:
name: nginx-lb
namespace: factor4
spec:
type: LoadBalancer
selector:
app: nginx
type: lb
ports:
- protocol: TCP
port: 80
---
apiVersion: v1
kind: Pod
metadata:
name: nginx-lb
namespace: factor4
labels:
app: nginx
type: lb
spec:
containers:
- name: nginx
image: nginx:alpine
28 changes: 28 additions & 0 deletions factor4/simple-nodePort.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# gcloud compute firewall-rules create test --allow tcp:NODEPORT
---
apiVersion: v1
kind: Service
metadata:
name: nginx-nodeport
namespace: factor4
spec:
type: NodePort
selector:
app: nginx
type: nodePort
ports:
- protocol: TCP
port: 80
---
apiVersion: v1
kind: Pod
metadata:
name: nginx-nodeport
namespace: factor4
labels:
app: nginx
type: nodePort
spec:
containers:
- name: nginx
image: nginx:alpine
30 changes: 30 additions & 0 deletions factor5/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: config-1
namespace: factor5
data:
nginx.properties: |-
config1=value1
config2=value2
config3=value3
---
apiVersion: v1
kind: ConfigMap
metadata:
name: config-2
namespace: factor5
data:
nginx.env1: myEnv1Value
---
apiVersion: v1
kind: Secret
metadata:
name: config-3
namespace: factor5
data:
type: Opaque
data:
username: YWRtaW4=
password: bXlfc2VjdXJlX3Bhc3N3b3Jk
Empty file added factor5/factor
Empty file.
33 changes: 33 additions & 0 deletions factor5/pod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
apiVersion: v1
kind: Pod
metadata:
name: nginx
namespace: factor5
spec:
volumes:
- name: nginx-config
configMap:
name: config-1
containers:
- name: nginx
image: nginx:alpine
volumeMounts:
- name: nginx-config
mountPath: /config
env:
- name: ENV_VAR_NGINX
valueFrom:
configMapKeyRef:
name: config-2
key: nginx.env1
- name: ENV_VAR_SECRET_USERNAME
valueFrom:
secretKeyRef:
name: config-3
key: username
- name: ENV_VAR_SECRET_PASSWORD
valueFrom:
secretKeyRef:
name: config-3
key: password
16 changes: 16 additions & 0 deletions factor6/pod-outofbound.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Pod
metadata:
name: stress-outofbound
namespace: factor6
spec:
containers:
- name: stress
image: polinux/stress
resources:
limits:
memory: "200Mi"
requests:
memory: "100Mi"
command: ["stress"]
args: ["--vm", "1", "--vm-bytes", "250M", "--vm-hang", "1"]
16 changes: 16 additions & 0 deletions factor6/pod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Pod
metadata:
name: stress
namespace: factor6
spec:
containers:
- name: stress
image: polinux/stress
resources:
limits:
memory: "200Mi"
requests:
memory: "100Mi"
command: ["stress"]
args: ["--vm", "1", "--vm-bytes", "150M", "--vm-hang", "1"]
21 changes: 21 additions & 0 deletions factor7/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deploy
namespace: factor7
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
#image: nginx:1.12.2-alpine
image: nginx:1.13.11-alpine
imagePullPolicy: Always
10 changes: 10 additions & 0 deletions factor7/pod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
namespace: factor7
spec:
containers:
- name: nginx
image: nginx:alpine
20 changes: 20 additions & 0 deletions factor7/rs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: nginx-rs
namespace: factor7
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
#image: nginx:1.12.2-alpine
image: nginx:1.13.11-alpine
22 changes: 22 additions & 0 deletions factor8/liveness-pod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v1
kind: Pod
metadata:
name: liveness-exec
namespace: factor8
spec:
containers:
- name: liveness
image: k8s.gcr.io/busybox
args:
- /bin/sh
- -c
- touch /tmp/healthy; sleep 15; rm -rf /tmp/healthy; sleep 600
livenessProbe:
exec:
command:
- cat
- /tmp/healthy
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 1
successThreshold: 1

0 comments on commit cd42c5d

Please sign in to comment.