Browse Source

add nextcloud ,ubuntu-ssh

liuyuqi-dellpc 5 years ago
commit
db43dc6208
40 changed files with 826 additions and 0 deletions
  1. 10 0
      .dockerignore
  2. 1 0
      .gitignore
  3. 0 0
      README.md
  4. 12 0
      docker/2048/README.md
  5. 32 0
      docker/2048/docker-compose.yml
  6. 18 0
      docker/django/Dockerfile
  7. 24 0
      docker/django/README.md
  8. 10 0
      docker/django/docker-compose.debug.yml
  9. 8 0
      docker/django/docker-compose.yml
  10. 24 0
      docker/django/manage.py
  11. 25 0
      docker/django/q.yml
  12. 17 0
      docker/django/requirements.txt
  13. 0 0
      docker/django/wxpay/__init__.py
  14. 10 0
      docker/nextcloud/Caddyfile
  15. 10 0
      docker/nextcloud/Dockerfile
  16. 14 0
      docker/nextcloud/docker-compose.debug.yml
  17. 32 0
      docker/nextcloud/docker-compose.yml
  18. 19 0
      docker/ubuntu-ssh/Dockerfile
  19. 13 0
      docker/ubuntu-ssh/README.md
  20. 49 0
      docker/ubuntu-ssh/sources.list
  21. 7 0
      docker/wordpress/Dockerfile
  22. 88 0
      docker/wordpress/README.md
  23. 10 0
      docker/wordpress/docker-compose.debug.yml
  24. 26 0
      docker/wordpress/docker-compose.yml
  25. 26 0
      docker/wordpress/docker-compose1.yml
  26. 20 0
      kubernetes/dao-2048/README.MD
  27. 12 0
      kubernetes/dao-2048/dao-2048-pod.yaml
  28. 3 0
      kubernetes/guestbook/README.md
  29. 29 0
      kubernetes/guestbook/frontend-controller.yaml
  30. 33 0
      kubernetes/guestbook/frontend-deployment.yaml
  31. 18 0
      kubernetes/guestbook/frontend-service.yaml
  32. 20 0
      kubernetes/guestbook/redis-master-controller.yaml
  33. 27 0
      kubernetes/guestbook/redis-master-deployment.yaml
  34. 13 0
      kubernetes/guestbook/redis-master-service.yaml
  35. 34 0
      kubernetes/guestbook/redis-slave-controller.yaml
  36. 35 0
      kubernetes/guestbook/redis-slave-deployment.yaml
  37. 15 0
      kubernetes/guestbook/redis-slave-service.yaml
  38. 20 0
      kubernetes/nginx/my-nginx-rc.yaml
  39. 50 0
      kubernetes/nginx/nginx-dep.yaml
  40. 12 0
      kubernetes/nginx/nginx-hpa.yaml

+ 10 - 0
.dockerignore

@@ -0,0 +1,10 @@
+node_modules
+npm-debug.log
+Dockerfile*
+docker-compose*
+.dockerignore
+.git
+.gitignore
+README.md
+LICENSE
+.vscode

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+/.idea

+ 0 - 0
README.md


+ 12 - 0
docker/2048/README.md

@@ -0,0 +1,12 @@
+## 2048
+
+https://github.com/jianboy/2048
+
+
+```
+# docker-compose命令启动:
+docker-compose up -d
+
+#docker swam:
+docker stack deploy -c docker-compose.yml deploy-demo
+```

+ 32 - 0
docker/2048/docker-compose.yml

@@ -0,0 +1,32 @@
+version: "3"
+
+services:
+  nginx:
+    image: daocloud.io/daocloud/dao-2048:v1.0.2
+    ports:
+      - 8081:80
+    deploy:
+      mode: replicated
+      replicas: 4
+
+  visualizer:
+    image: 192.168.99.100:5000/dockersamples/visualizer:latest
+    ports:
+      - "8080:8080"
+    volumes:
+      - "/var/run/docker.sock:/var/run/docker.sock"
+    deploy:
+      replicas: 1
+      placement:
+        constraints: [node.role == manager]
+
+  portainer:
+    image: 192.168.99.100:5000/portainer/portainer:latest
+    ports:
+      - "9000:9000"
+    volumes:
+      - "/var/run/docker.sock:/var/run/docker.sock"
+    deploy:
+      replicas: 1
+      placement:
+        constraints: [node.role == manager]

+ 18 - 0
docker/django/Dockerfile

@@ -0,0 +1,18 @@
+FROM daocloud.io/library/django:1.7.4-python3
+
+RUN mkdir /usr/src/app
+ADD . /usr/src/app/
+WORKDIR /usr/src/app/
+RUN mkdir ~/.pip
+RUN cat > ~/.pip/pip.conf << EOF
+[global]
+trusted-host=mirrors.aliyun.com
+index-url=https://mirrors.aliyun.com/pypi/simple/
+EOF
+
+# RUN pip install -r requirements.txt
+
+LABEL Name=doo Version=0.0.1
+EXPOSE 3000
+
+CMD [ "python","./manage.py","runsesrver" ]

+ 24 - 0
docker/django/README.md

@@ -0,0 +1,24 @@
+# build:
+
+docker build -t my-django-app .
+docker run --name some-django-app -d my-django-app
+
+你可以访问http://容器 IP:8000 来测试,如果想要通过主机 IP 来访问(如 http://localhost:8000),要执行下面的命令:
+
+docker run --name some-django-app -p 8000:8000 -d my-django-app
+
+
+
+
+docker build -t my-python-app .
+docker run -it --rm --name my-running-app my-python-app
+
+
+docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp daocloud.io/python:3 python your-daemon-or-script.py
+
+
+或者:
+docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp daocloud.io/python:2 python your-daemon-or-script.py
+
+
+github.com/jianboy/dao:v1.4

+ 10 - 0
docker/django/docker-compose.debug.yml

@@ -0,0 +1,10 @@
+version: '2.1'
+
+services:
+  d:
+    image: d
+    build:
+      context: .
+      dockerfile: Dockerfile
+    ports:
+        - 3000:3000

+ 8 - 0
docker/django/docker-compose.yml

@@ -0,0 +1,8 @@
+version: '2.1'
+
+services:
+  doo:
+    image: doo
+    build: .
+    ports:
+      - 3000:3000

+ 24 - 0
docker/django/manage.py

@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+'''
+@Auther :liuyuqi.gov@msn.cn
+@date :2019/2/21
+'''
+__author__ = "liuyuqi"
+
+import os
+import sys
+
+
+if __name__ == "__main__":
+    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djangoWechat.settings")
+    try:
+        from django.core.management import execute_from_command_line
+    except ImportError as exc:
+        raise ImportError(
+            "Couldn't import Django. Are you sure it's installed and "
+            "available on your PYTHONPATH environment variable? Did you "
+            "forget to activate a virtual environment?"
+        ) from exc
+    execute_from_command_line(sys.argv)
+

+ 25 - 0
docker/django/q.yml

@@ -0,0 +1,25 @@
+version: '3'
+services:
+   db:
+     image: daocloud.io/mysql:5.7.4
+     volumes:
+       - /data/db_data:/var/lib/mysql
+     restart: always
+     environment:
+       MYSQL_ROOT_PASSWORD: somewordpress
+       MYSQL_DATABASE: wordpress
+       MYSQL_USER: wordpress
+       MYSQL_PASSWORD: wordpress
+   wordpress:
+     depends_on:
+       - db
+     image: daocloud.io/library/wordpress:4.2.1-apache
+     volumes:
+       - /data/web_data:/var/www/html
+     ports: 
+       - "8000:80"
+     restart: always
+     environment:
+       WORDPRESS_DB_HOST: db:3306
+       WORDPRESS_DB_USER: wordpress
+       WORDPRESS_DB_PASSWORD: wordpress

+ 17 - 0
docker/django/requirements.txt

@@ -0,0 +1,17 @@
+asn1crypto==0.24.0
+certifi==2018.4.16
+cffi==1.11.5
+chardet==3.0.4
+cryptography==2.2.2
+Django==2.0.6
+djangorestframework==3.8.2
+idna==2.7
+optionaldict==0.1.1
+pycparser==2.18
+python-dateutil==2.7.3
+pytz==2018.4
+requests==2.19.1
+six==1.11.0
+urllib3==1.23
+wechatpy==1.7.0
+xmltodict==0.11.0

+ 0 - 0
docker/django/wxpay/__init__.py


+ 10 - 0
docker/nextcloud/Caddyfile

@@ -0,0 +1,10 @@
+nextcloud.yoqi.me
+
+errors error.log {
+    404 https://error.yuuno.cc
+}
+
+proxy / app:80 {
+    transparent
+    header_downstream Content-Security-Policy none
+}

+ 10 - 0
docker/nextcloud/Dockerfile

@@ -0,0 +1,10 @@
+
+FROM openjdk:8-jdk-alpine
+VOLUME /tmp
+ARG JAVA_OPTS
+ENV JAVA_OPTS=$JAVA_OPTS
+ADD d.jar d.jar
+EXPOSE 3000
+ENTRYPOINT exec java $JAVA_OPTS -jar d.jar
+# For Spring-Boot project, use the entrypoint below to reduce Tomcat startup time.
+#ENTRYPOINT exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar d.jar

+ 14 - 0
docker/nextcloud/docker-compose.debug.yml

@@ -0,0 +1,14 @@
+version: '2.1'
+
+services:
+  d:
+    image: d
+    build:
+      context: .
+      dockerfile: Dockerfile
+    environment:
+      JAVA_OPTS: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005,quiet=y
+    ports:
+      - 3000:3000
+      - 5005:5005
+    

+ 32 - 0
docker/nextcloud/docker-compose.yml

@@ -0,0 +1,32 @@
+version: '3'
+
+services:
+  app:
+    image: nextcloud:12
+    restart: unless-stopped
+    volumes:
+      - nextcloud:/var/www/html
+
+  web:
+    image: abiosoft/caddy
+    restart: unless-stopped
+    privileged: true
+    volumes:
+      - ./Caddyfile:/etc/Caddyfile
+      - caddy:/root/.caddy
+    environment:
+      - VIRTUAL_HOST=193.112.96.151
+    links:
+      - app
+    ports:
+      - 80:80
+      - 443:443
+    networks:
+      - default
+
+volumes:
+  nextcloud:
+  caddy:
+
+networks:
+  default:

+ 19 - 0
docker/ubuntu-ssh/Dockerfile

@@ -0,0 +1,19 @@
+FROM daocloud.io/library/ubuntu:18.10
+#sources.list添加阿里云镜像
+ADD sources.list /root/sources.list
+# RUN cp /root/sources.list  /etc/apt/sources.list.d/aliyun.list
+RUN cp /root/sources.list  /etc/apt/sources.list
+RUN apt-get update
+
+LABEL Name=github.com/jianboy/ubuntu-ssh Version=18.10
+
+#安装ssh
+RUN apt-get install -y openssh-server
+RUN mkdir -p /var/run/sshd
+#默认用户名密码 root:password
+RUN echo 'root:password' | chpasswd
+RUN sed -ri 's/^#PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config
+RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config
+
+EXPOSE 22
+CMD ["/usr/sbin/sshd", "-D"]

+ 13 - 0
docker/ubuntu-ssh/README.md

@@ -0,0 +1,13 @@
+## ubuntu-ssh
+
+根据 Dockerfile 构建镜像,实现 ssh 登录容器的功能:
+
+```
+docker build -t git.yoqi.me/docker/ubuntu-ssh:18.10 .
+```
+
+启动容器:
+
+```
+docker run --rm -it -p 2223:22/tcp ubuntu-ssh:18.10
+```

+ 49 - 0
docker/ubuntu-ssh/sources.list

@@ -0,0 +1,49 @@
+# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
+# newer versions of the distribution.
+deb http://mirrors.aliyun.com/ubuntu/ cosmic main restricted
+# deb-src http://mirrors.aliyun.com/ubuntu/ cosmic main restricted
+
+## Major bug fix updates produced after the final release of the
+## distribution.
+deb http://mirrors.aliyun.com/ubuntu/ cosmic-updates main restricted
+# deb-src http://mirrors.aliyun.com/ubuntu/ cosmic-updates main restricted
+
+## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
+## team. Also, please note that software in universe WILL NOT receive any
+## review or updates from the Ubuntu security team.
+deb http://mirrors.aliyun.com/ubuntu/ cosmic universe
+# deb-src http://mirrors.aliyun.com/ubuntu/ cosmic universe
+deb http://mirrors.aliyun.com/ubuntu/ cosmic-updates universe
+# deb-src http://mirrors.aliyun.com/ubuntu/ cosmic-updates universe
+
+## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
+## team, and may not be under a free licence. Please satisfy yourself as to
+## your rights to use the software. Also, please note that software in
+## multiverse WILL NOT receive any review or updates from the Ubuntu
+## security team.
+deb http://mirrors.aliyun.com/ubuntu/ cosmic multiverse
+# deb-src http://mirrors.aliyun.com/ubuntu/ cosmic multiverse
+deb http://mirrors.aliyun.com/ubuntu/ cosmic-updates multiverse
+# deb-src http://mirrors.aliyun.com/ubuntu/ cosmic-updates multiverse
+
+## N.B. software from this repository may not have been tested as
+## extensively as that contained in the main release, although it includes
+## newer versions of some applications which may provide useful features.
+## Also, please note that software in backports WILL NOT receive any review
+## or updates from the Ubuntu security team.
+deb http://mirrors.aliyun.com/ubuntu/ cosmic-backports main restricted universe multiverse
+# deb-src http://mirrors.aliyun.com/ubuntu/ cosmic-backports main restricted universe multiverse
+
+## Uncomment the following two lines to add software from Canonical's
+## 'partner' repository.
+## This software is not part of Ubuntu, but is offered by Canonical and the
+## respective vendors as a service to Ubuntu users.
+# deb http://archive.canonical.com/ubuntu cosmic partner
+# deb-src http://archive.canonical.com/ubuntu cosmic partner
+
+deb http://security.ubuntu.com/ubuntu/ cosmic-security main restricted
+# deb-src http://security.ubuntu.com/ubuntu/ cosmic-security main restricted
+deb http://security.ubuntu.com/ubuntu/ cosmic-security universe
+# deb-src http://security.ubuntu.com/ubuntu/ cosmic-security universe
+deb http://security.ubuntu.com/ubuntu/ cosmic-security multiverse
+# deb-src http://security.ubuntu.com/ubuntu/ cosmic-security multiverse

+ 7 - 0
docker/wordpress/Dockerfile

@@ -0,0 +1,7 @@
+FROM daocloud.io/library/wordpress:4.2.1-apache
+
+LABEL Name=d Version=0.0.1
+EXPOSE 3000
+
+WORKDIR /app
+ADD . /app

+ 88 - 0
docker/wordpress/README.md

@@ -0,0 +1,88 @@
+## wordpress
+
+1. 启动1个 wordpress 容器
+
+使用docker-compose.yml文件,执行如下命令启动:
+
+```
+docker-compose up -d
+```
+访问:http://http://192.168.99.100:8080
+
+2. 启动2个 wordpress 容器:
+
+同时启动两个 wordpress 容器,实现负载均衡,不暴露端口,使用docker-compose1.yml文件:
+
+```
+docker-compose scale wordpress=2 
+```
+
+然后在主机中安装 haproxy 实现负载均衡:
+
+```
+yum install haproxy -y
+```
+
+修改配置文件:
+
+```
+cp /etc/haproxy/haproxy.cfg{,.bak}
+vim /etc/haproxy/haproxy.cfg
+
+global
+    log         127.0.0.1 local2
+    chroot      /var/lib/haproxy
+    pidfile     /var/run/haproxy.pid
+    maxconn     4000
+    user        haproxy
+    group       haproxy
+    daemon
+    stats socket /var/lib/haproxy/stats level admin  #支持命令行控制
+defaults
+    mode                    http
+    log                     global
+    option                  httplog
+    option                  dontlognull
+    option http-server-close
+    option forwardfor       except 127.0.0.0/8
+    option                  redispatch
+    retries                 3
+    timeout http-request    10s
+    timeout queue           1m
+    timeout connect         10s
+    timeout client          1m
+    timeout server          1m
+    timeout http-keep-alive 10s
+    timeout check           10s
+    maxconn                 3000
+listen stats
+    mode http
+    bind 0.0.0.0:8888
+    stats enable
+    stats uri     /haproxy-status 
+    stats auth    admin:123456
+frontend frontend_www_example_com
+    bind 10.0.0.100:8000
+    mode http
+    option httplog
+    log global
+    default_backend backend_www_example_com
+backend backend_www_example_com
+    option forwardfor header X-REAL-IP
+    option httpchk HEAD / HTTP/1.0
+    balance roundrobin
+    server web-node1  10.0.0.100:32768 check inter 2000 rise 30 fall 15
+    server web-node2  10.0.0.100:32769 check inter 2000 rise 30 fall 15
+
+```
+
+启动haproxy:
+```
+systemctl start haproxy
+systemctl enable haproxy
+
+```
+浏览器访问:
+http://192.168.99.100:8888/haproxy-status
+
+

+ 10 - 0
docker/wordpress/docker-compose.debug.yml

@@ -0,0 +1,10 @@
+version: '2.1'
+
+services:
+  d:
+    image: d
+    build:
+      context: .
+      dockerfile: Dockerfile
+    ports:
+      - 3000:3000

+ 26 - 0
docker/wordpress/docker-compose.yml

@@ -0,0 +1,26 @@
+version: '2.1'
+
+services:
+   db:
+     image: daocloud.io/mysql:5.7.4
+     volumes:
+       - /data/db_data:/var/lib/mysql
+     restart: always
+     environment:
+       MYSQL_ROOT_PASSWORD: somewordpress
+       MYSQL_DATABASE: wordpress
+       MYSQL_USER: wordpress
+       MYSQL_PASSWORD: 123456
+   wordpress:
+     depends_on:
+       - db
+     image: daocloud.io/library/wordpress:4.2.1-apache
+     volumes:
+       - /data/web_data:/var/www/html
+     ports: 
+       - "8080:80"
+     restart: always
+     environment:
+       WORDPRESS_DB_HOST: db:3306
+       WORDPRESS_DB_USER: wordpress
+       WORDPRESS_DB_PASSWORD: 123456

+ 26 - 0
docker/wordpress/docker-compose1.yml

@@ -0,0 +1,26 @@
+version: '2.1'
+
+services:
+   db:
+     image: daocloud.io/mysql:5.7.4
+     volumes:
+       - /data/db_data:/var/lib/mysql
+     restart: always
+     environment:
+       MYSQL_ROOT_PASSWORD: somewordpress
+       MYSQL_DATABASE: wordpress
+       MYSQL_USER: wordpress
+       MYSQL_PASSWORD: wordpress
+   wordpress:
+     depends_on:
+       - db
+     image: daocloud.io/library/wordpress:4.2.1-apache
+     volumes:
+       - /data/web_data:/var/www/html
+     ports: 
+       - "80"
+     restart: always
+     environment:
+       WORDPRESS_DB_HOST: db:3306
+       WORDPRESS_DB_USER: wordpress
+       WORDPRESS_DB_PASSWORD: wordpress

+ 20 - 0
kubernetes/dao-2048/README.MD

@@ -0,0 +1,20 @@
+
+##  dao-2048
+
+```
+kubectl create -f dao-2048-pod.yaml
+
+kubectl get pod dao-2048
+kubectl get pod dao-2048 --output json
+kubectl get pod dao-2048 --output yaml
+
+kubectl describe pod dao-2048
+
+kubectl get logs dao-2048
+
+kubectl delete pod dao-2048
+
+# 进入Pod
+kubectl exec -it dao-2048 /bin/sh
+
+```

+ 12 - 0
kubernetes/dao-2048/dao-2048-pod.yaml

@@ -0,0 +1,12 @@
+kind: Pod
+apiVersion: v1
+metadata:
+  name: dao-2048
+  labels:
+    name: dao-2048
+spec:
+  containers:
+  - name: dao-2048
+    image: daocloud.io/daocloud/dao-2048:v1.0.2
+    ports:
+      - containerPort: 80

+ 3 - 0
kubernetes/guestbook/README.md

@@ -0,0 +1,3 @@
+## guestbook
+
+

+ 29 - 0
kubernetes/guestbook/frontend-controller.yaml

@@ -0,0 +1,29 @@
+apiVersion: v1
+kind: ReplicationController
+metadata:
+  name: frontend
+spec:
+  replicas: 3
+  template:
+    metadata:
+      labels:
+        app: guestbook
+        tier: frontend
+    spec:
+      containers:
+      - name: php-redis
+        image: anjia0532/google-samples.gb-frontend:v4
+        resources:
+          requests:
+            cpu: 100m
+            memory: 100Mi
+        env:
+        - name: GET_HOSTS_FROM
+          value: dns
+          # If your cluster config does not include a dns service, then to
+          # instead access environment variables to find service host
+          # info, comment out the 'value: dns' line above, and uncomment the
+          # line below:
+          # value: env
+        ports:
+        - containerPort: 80

+ 33 - 0
kubernetes/guestbook/frontend-deployment.yaml

@@ -0,0 +1,33 @@
+apiVersion: v1 #  for k8s versions before 1.9.0 use apps/v1beta2  and before 1.8.0 use extensions/v1beta1
+kind: Deployment
+metadata:
+  name: frontend
+spec:
+  selector:
+    matchLabels:
+      app: guestbook
+      tier: frontend
+  replicas: 3
+  template:
+    metadata:
+      labels:
+        app: guestbook
+        tier: frontend
+    spec:
+      containers:
+        - name: php-redis
+          image: gcr.io/google-samples/gb-frontend:v4
+          resources:
+            requests:
+              cpu: 100m
+              memory: 100Mi
+          env:
+            - name: GET_HOSTS_FROM
+              value: dns
+              # If your cluster config does not include a dns service, then to
+              # instead access environment variables to find service host
+              # info, comment out the 'value: dns' line above, and uncomment the
+              # line below:
+              # value: env
+          ports:
+            - containerPort: 80

+ 18 - 0
kubernetes/guestbook/frontend-service.yaml

@@ -0,0 +1,18 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: frontend
+  labels:
+    app: guestbook
+    tier: frontend
+spec:
+  # comment or delete the following line if you want to use a LoadBalancer
+  type: NodePort
+  # if your cluster supports it, uncomment the following to automatically create
+  # an external load-balanced IP for the frontend service.
+  # type: LoadBalancer
+  ports:
+    - port: 80
+  selector:
+    app: guestbook
+    tier: frontend

+ 20 - 0
kubernetes/guestbook/redis-master-controller.yaml

@@ -0,0 +1,20 @@
+apiVersion: v1
+kind: ReplicationController
+metadata:
+  name: redis-master
+  labels:
+    name: redis-master
+spec:
+  replicas: 1
+  selector:
+    name: redis-master
+  template:
+    metadata:
+      labels:
+        name: redis-master
+    spec:
+      containers:
+        - name: master
+          image: redis:latest
+          ports:
+            - containerPort: 6379

+ 27 - 0
kubernetes/guestbook/redis-master-deployment.yaml

@@ -0,0 +1,27 @@
+apiVersion: apps/v1 #  for k8s versions before 1.9.0 use apps/v1beta2  and before 1.8.0 use extensions/v1beta1
+kind: Deployment
+metadata:
+  name: redis-master
+spec:
+  selector:
+    matchLabels:
+      app: redis
+      role: master
+      tier: backend
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: redis
+        role: master
+        tier: backend
+    spec:
+      containers:
+        - name: master
+          image: k8s.gcr.io/redis:e2e # or just image: redis
+          resources:
+            requests:
+              cpu: 100m
+              memory: 100Mi
+          ports:
+            - containerPort: 6379

+ 13 - 0
kubernetes/guestbook/redis-master-service.yaml

@@ -0,0 +1,13 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: redis-master
+  labels:
+    name: redis-master
+spec:
+  ports:
+    # the port that this service should serve on
+    - port: 6379
+      targetPort: 6379
+  selector:
+    name: redis-master

+ 34 - 0
kubernetes/guestbook/redis-slave-controller.yaml

@@ -0,0 +1,34 @@
+apiVersion: v1
+kind: ReplicationController
+metadata:
+  name: redis-slave
+  labels:
+    app: redis
+    role: slave
+    tier: backend
+spec:
+  replicas: 2
+  template:
+    metadata:
+      labels:
+        app: redis
+        role: slave
+        tier: backend
+    spec:
+      containers:
+      - name: slave
+        image: redis:latest
+        resources:
+          requests:
+            cpu: 100m
+            memory: 100Mi
+        env:
+        - name: GET_HOSTS_FROM
+          value: dns
+          # If your cluster config does not include a dns service, then to
+          # instead access an environment variable to find the master
+          # service's host, comment out the 'value: dns' line above, and
+          # uncomment the line below:
+          # value: env
+        ports:
+        - containerPort: 6379

+ 35 - 0
kubernetes/guestbook/redis-slave-deployment.yaml

@@ -0,0 +1,35 @@
+apiVersion: apps/v1 #  for k8s versions before 1.9.0 use apps/v1beta2  and before 1.8.0 use extensions/v1beta1
+kind: Deployment
+metadata:
+  name: redis-slave
+spec:
+  selector:
+    matchLabels:
+      app: redis
+      role: slave
+      tier: backend
+  replicas: 2
+  template:
+    metadata:
+      labels:
+        app: redis
+        role: slave
+        tier: backend
+    spec:
+      containers:
+        - name: slave
+          image: gcr.io/google_samples/gb-redisslave:v1
+          resources:
+            requests:
+              cpu: 100m
+              memory: 100Mi
+          env:
+            - name: GET_HOSTS_FROM
+              value: dns
+              # If your cluster config does not include a dns service, then to
+              # instead access an environment variable to find the master
+              # service's host, comment out the 'value: dns' line above, and
+              # uncomment the line below:
+              # value: env
+          ports:
+            - containerPort: 6379

+ 15 - 0
kubernetes/guestbook/redis-slave-service.yaml

@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: redis-slave
+  labels:
+    app: redis
+    role: slave
+    tier: backend
+spec:
+  ports:
+  - port: 6379
+  selector:
+    app: redis
+    role: slave
+    tier: backend

+ 20 - 0
kubernetes/nginx/my-nginx-rc.yaml

@@ -0,0 +1,20 @@
+apiVersion: v1
+kind: ReplicationController
+metadata:
+  name: redis-master
+  labels:
+    name: redis-master
+spec:
+  replicas: 1
+  selector:
+    name: redis-master
+  template:
+    metadata:
+      labels:
+        name: redis-master
+    spec:
+      containers:
+      - name: master
+        image: redis:lastest
+        ports:
+        - containerPort: 6379

+ 50 - 0
kubernetes/nginx/nginx-dep.yaml

@@ -0,0 +1,50 @@
+apiVersion: extensions/v1beta1
+kind: Deployment
+metadata:
+  name:  my-name
+  labels:
+    name:  my-name
+spec:
+  strategy:
+    rollingUpdate:
+      maxSurge: 1
+      maxUnavailable: 1
+    type: RollingUpdate
+  template:
+    metadata:
+      labels:
+        name:  my-name
+    spec:
+      containers:
+      - image:  ipedrazas/docmock
+        name:  my-name
+        resources:
+          requests:
+            cpu: "20m"
+            memory: "55M"
+        livenessProbe:
+          httpGet:
+            path: /_status/healthz
+            port: 5000
+          initialDelaySeconds: 90
+          timeoutSeconds: 10
+        readinessProbe:
+          httpGet:
+            path: /_status/healthz
+            port: 5000
+          initialDelaySeconds: 30
+          timeoutSeconds: 10
+        env:
+        - name:  ENVVARNAME
+          value:  ENVVARVALUE       
+        ports:
+        - containerPort:  5000
+          name:  my-name
+        volumeMounts:
+        - mountPath: /data
+          name: data
+      volumes:
+        - name: data
+          emptyDir: {}
+      restartPolicy: Always
+      imagePullPolicy: Always

+ 12 - 0
kubernetes/nginx/nginx-hpa.yaml

@@ -0,0 +1,12 @@
+kind: HorizontalPodAutoscaler
+apiVersion: extensions/v1beat1
+metadata:
+  name: myapp
+  labels:
+    name: myapp
+spec:
+  containers:
+  - name: myapp
+    image: <Image>
+    ports:
+      - containerPort: <Port>