Skip to content

Commit

Permalink
feat: refactor (#1)
Browse files Browse the repository at this point in the history
* feat: refactor

* feat: rename repo

* feat: fix ingress
  • Loading branch information
alexouzounis committed May 8, 2020
1 parent 4f3d3a8 commit d010921
Show file tree
Hide file tree
Showing 19 changed files with 210 additions and 102 deletions.
8 changes: 5 additions & 3 deletions 01-docker-nginx/run.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

docker run --rm --name nginx \
-v $HOME/solarstorm:/var/git/solarstorm:ro \
-v $HOME/solarstorm/conf/default.conf:/var/conf/default.conf:ro \
-v $DIR/../:/var/git/k8sprimitives1:ro \
-v $DIR/../conf/default.conf:/var/conf/default.conf:ro \
-e CONF_TEMPLATE=/var/conf/default.conf \
-e HTML_PATH=/var/git/solarstorm/resources/cats \
-e HTML_PATH=/var/git/k8sprimitives1/resources/dogs \
-p 8080:80 \
-d belitre/nginx:0.1
6 changes: 3 additions & 3 deletions 02-docker-git-sync/run.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.."

mkdir -p $DIR/git_repo

docker run --rm \
-v $DIR/git_repo:/git \
-e GIT_SYNC_REPO=https://github.com/belitre/solarstorm \
-e GIT_SYNC_REPO=https://github.com/ouzi-dev/k8sprimitives1 \
-e GIT_SYNC_BRANCH=master \
-e GIT_SYNC_ONE_TIME=true \
-e GYT_SYNC_DEST=solarstorm \
-e GYT_SYNC_DEST=k8sprimitives1 \
belitre/git-sync:0.1
2 changes: 1 addition & 1 deletion 03-pod/configmap.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

kubectl create configmap nginx-template --from-file=default.conf --dry-run -o yaml -n miguelsantiago
kubectl create configmap nginx-template --from-file=default.conf --dry-run -o yaml -n k8sprimitives1
2 changes: 1 addition & 1 deletion 03-pod/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-template
namespace: miguelsantiago
namespace: k8sprimitives1
data:
default.conf: |-
server {
Expand Down
22 changes: 18 additions & 4 deletions 03-pod/pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ kind: Pod
apiVersion: v1
metadata:
name: kittens-web-server
namespace: miguelsantiago
namespace: k8sprimitives1
labels:
app: nginx
release: kittens
Expand All @@ -15,7 +15,7 @@ spec:
- name: CONF_TEMPLATE
value: '/var/conf/default.conf'
- name: HTML_PATH
value: '/var/git/solarstorm/resources/cats'
value: '/var/git/k8sprimitives1/resources/cats'
ports:
- containerPort: 80
protocol: TCP
Expand All @@ -27,21 +27,35 @@ spec:
- name: nginx-conf
readOnly: true
mountPath: /var/conf
resources:
limits:
cpu: "0.1"
memory: "50M"
requests:
cpu: "0.1"
memory: "50M"
- name: git-sync
image: 'index.docker.io/belitre/git-sync:0.1'
imagePullPolicy: IfNotPresent
env:
- name: GIT_SYNC_REPO
value: 'https://github.com/belitre/solarstorm'
value: 'https://github.com/ouzi-dev/k8sprimitives1'
- name: GIT_SYNC_BRANCH
value: master
- name: GIT_SYNC_WAIT
value: '300'
- name: GIT_SYNC_DEST
value: solarstorm
value: k8sprimitives1
volumeMounts:
- name: git-repo
mountPath: /git
resources:
limits:
cpu: "0.1"
memory: "50M"
requests:
cpu: "0.1"
memory: "50M"
volumes:
- name: git-repo
emptyDir: {}
Expand Down
16 changes: 16 additions & 0 deletions 04-deployment/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-template
namespace: k8sprimitives1
data:
default.conf: |-
server {
listen 80;
server_name localhost;
location / {
root _HTML_PATH_;
index index.html index.htm;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ kind: Deployment
apiVersion: apps/v1
metadata:
name: dogs-deployment
namespace: k8sprimitives1
labels:
app: nginx
release: dogs
Expand All @@ -25,7 +26,7 @@ spec:
- name: CONF_TEMPLATE
value: '/var/conf/default.conf'
- name: HTML_PATH
value: '/var/git/solarstorm/resources/dogs'
value: '/var/git/k8sprimitives1/resources/dogs'
ports:
- containerPort: 80
protocol: TCP
Expand All @@ -37,21 +38,35 @@ spec:
- name: nginx-conf
readOnly: true
mountPath: /var/conf
resources:
limits:
cpu: "0.1"
memory: "50M"
requests:
cpu: "0.1"
memory: "50M"
- name: git-sync
image: 'index.docker.io/belitre/git-sync:0.1'
imagePullPolicy: IfNotPresent
env:
- name: GIT_SYNC_REPO
value: 'https://github.com/belitre/solarstorm'
value: 'https://github.com/ouzi-dev/k8sprimitives1'
- name: GIT_SYNC_BRANCH
value: master
- name: GIT_SYNC_WAIT
value: '300'
- name: GIT_SYNC_DEST
value: solarstorm
value: k8sprimitives1
volumeMounts:
- name: git-repo
mountPath: /git
resources:
limits:
cpu: "0.1"
memory: "50M"
requests:
cpu: "0.1"
memory: "50M"
volumes:
- name: git-repo
emptyDir: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ kind: Deployment
apiVersion: apps/v1
metadata:
name: kittens-deployment
namespace: k8sprimitives1
labels:
app: nginx
release: kittens
Expand All @@ -25,7 +26,7 @@ spec:
- name: CONF_TEMPLATE
value: '/var/conf/default.conf'
- name: HTML_PATH
value: '/var/git/solarstorm/resources/cats'
value: '/var/git/k8sprimitives1/resources/cats'
ports:
- containerPort: 80
protocol: TCP
Expand All @@ -37,21 +38,35 @@ spec:
- name: nginx-conf
readOnly: true
mountPath: /var/conf
resources:
limits:
cpu: "0.1"
memory: "50M"
requests:
cpu: "0.1"
memory: "50M"
- name: git-sync
image: 'index.docker.io/belitre/git-sync:0.1'
imagePullPolicy: IfNotPresent
env:
- name: GIT_SYNC_REPO
value: 'https://github.com/belitre/solarstorm'
value: 'https://github.com/ouzi-dev/k8sprimitives1'
- name: GIT_SYNC_BRANCH
value: master
- name: GIT_SYNC_WAIT
value: '300'
- name: GIT_SYNC_DEST
value: solarstorm
value: k8sprimitives1
volumeMounts:
- name: git-repo
mountPath: /git
resources:
limits:
cpu: "0.1"
memory: "50M"
requests:
cpu: "0.1"
memory: "50M"
volumes:
- name: git-repo
emptyDir: {}
Expand Down
5 changes: 3 additions & 2 deletions 06-loadbalancer/service.yaml → 05-service/service-dogs.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: dogs-nodeport
name: dogs
namespace: k8sprimitives1
labels:
app: nginx
release: dogs
spec:
type: NodePort
type: ClusterIP
ports:
- port: 80
name: http
Expand Down
5 changes: 3 additions & 2 deletions 04-service/service.yaml → 05-service/service-kittens.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: kittens-nodeport
name: kittens
namespace: k8sprimitives1
labels:
app: nginx
release: kittens
spec:
type: NodePort
type: ClusterIP
ports:
- port: 80
name: http
Expand Down
5 changes: 3 additions & 2 deletions 06-loadbalancer/service-lb.yaml → 05-service/service.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: lb-nodeport
name: all
namespace: k8sprimitives1
labels:
app: nginx
spec:
type: NodePort
type: ClusterIP
ports:
- port: 80
name: http
Expand Down
29 changes: 29 additions & 0 deletions 06-ingress/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: kitten-ingress
namespace: k8sprimitives1
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
rules:
- host: k8sprimitives1.k8sdemos.test-infra.ouzi.io
http:
paths:
- path: /kittens(/|$)(.*)
backend:
serviceName: kittens
servicePort: http
- path: /dogs(/|$)(.*)
backend:
serviceName: dogs
servicePort: http
- path: /random(/|$)(.*)
backend:
serviceName: all
servicePort: http
tls:
- hosts:
- k8sprimitives1.k8sdemos.test-infra.ouzi.io
secretName: k8sprimitives1-cert
26 changes: 0 additions & 26 deletions 07-ingress/ingress.yaml

This file was deleted.

49 changes: 0 additions & 49 deletions 07-ingress/services.yaml

This file was deleted.

Loading

0 comments on commit d010921

Please sign in to comment.