k8s google sample - guestbook
Redis读写分离作为存储
PHP网页作为前端
github地址
https://github.com/kubernetes/kubernetes/blob/release-1.1/examples/guestbook/README.md
Create guest book sample on k8s
1. 创建Redis写端RC yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: redis-master
labels:
name: redis-master
spec:
replicas:
selector:
name: redis-master
template:
metadata:
labels:
name: redis-master
spec:
containers:
- name: master
image: redis
ports:
- containerPort:
可以到开头的github地址下载dockfile,自己创建image
2. k8s创建RC redis master
kubectl create -f redis-master-controller.yaml
3. k8s创建 redis master service yaml
apiVersion: v1
kind: Service
metadata:
name: redis-master
labels:
name: redis-master
spec:
ports:
# the port that this service should serve on
- port:
targetPort:
selector:
name: redis-master
4. k8s创建SVC
kubectl create -f redis-master-service.yaml
5. 创建Redis读端 RC redis slave yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: redis-slave
labels:
name: redis-slave
spec:
replicas:
selector:
name: redis-slave
template:
metadata:
labels:
name: redis-slave
spec:
containers:
- name: slave
image: kubeguide/guestbook-redis-slave
env:
- name: GET_HOSTS_FROM
value: env
# 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:
示例文档中说明如果放在云端并且有DNS服务器可以写入dns,但是实验中是在局域网内,所以使用env
6. k8s创建redis slave RC
kubectl create -f redis-slave-controller.yaml
7. 创建redis slave svc yaml
apiVersion: v1
kind: Service
metadata:
name: redis-slave
labels:
name: redis-slave
spec:
ports:
# the port that this service should serve on
- port:
selector:
name: redis-slave
8. k8s创建redis slave svc
kubectl create -f redis-slave-service.yaml
9. 创建php frontend rc yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: frontend
labels:
name: frontend
spec:
replicas:
selector:
name: frontend
template:
metadata:
labels:
name: frontend
spec:
containers:
- name: frontend
image: peter/php-frontend:v1
env:
- name: GET_HOSTS_FROM
value: env
# 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:
这是下载了github的dockfile,本地构建的镜像

10. k8s创建 php frontend rc
kubectl create -f frontend-controller.yaml
11. 创建php frontend svc yaml
apiVersion: v1
kind: Service
metadata:
name: frontend
labels:
name: frontend
spec:
# if your cluster supports it, uncomment the following to automatically create
# an external load-balanced IP for the frontend service.
type: NodePort
ports:
# the port that this service should serve on
- port:
nodePort: 30001
selector:
name: frontend
打开节点机器30001端口
12. k8s创建php frontend svc
kubectl create -f frontend-service.yaml
查看k8s的pods svc rc

输入node机器的ip:30001即可访问

Scale
k8s执行命令
kubectl scale --current-replicas=2 --replicas=3 replicationcontrollers redis-slave

Rolling update
k8s执行命令
kubectl rolling-update frontend --image=peter/php-frontend:v3

k8s google sample - guestbook的更多相关文章
- k8s API sample
Declarative API k8s: cluster-api Introduction to Kubernetes Cluster-API Project Declarative Manageme ...
- Android高效计算——RenderScript(二)
3 RenderScript运行时层与反射层 3.1 RenderScript运行时层 RenderScript运行时层是指.rs代码运行时所在的层级.当对安卓项目进行编译的时候,.rs或者.rsh中 ...
- APP架子迁移指南(三)
在完成上一篇之后,断断续续的开始重构我的Android项目代码,现在终于完成了.在重构期间又仔细阅读了一些开源项目的源码及文章,并询问了一些大神思路,按照理解自己完成了MVP结构的重构,与google ...
- Android Studio 2.2 来啦
今年的 I/O 2016 Google 放出了 Android Studio 2.2 的预览版,改进了多项功能,只不过为了保证公司项目不受影响,我一般都不安装预览版的,因为预览版意味着不稳定,可能遇到 ...
- APP迁移
APP架子迁移 在完成上一篇之后,断断续续的开始重构我的Android项目代码,现在终于完成了.在重构期间又仔细阅读了一些开源项目的源码及文章,并询问了一些大神思路,按照理解自己完成了MVP结构的重构 ...
- Lichee(三) Android4.0该产品的目标文件夹,Lichee链接---extract-bsp
由<Lichee() 在sun4i_crane平台下的编译>介绍了编译lichee的基本情况,我们终于得到了编译后的结果例如以下: out/ ├── android │ ├── bIm ...
- Orleans部署
一.配置指南 1,客户端配置 2,服务端配置 3,典型配置 4,配置.NET垃圾收集 5,SQL系统存储 二.监控 1,运行时监视 2,silo错误代码监测 3,客户端错误代码监测 三.解决部署问题 ...
- <Android 基础(四)> RecyclerView
介绍 RecyclerView是ListView的豪华增强版.它主要包含以下几处新的特性,如ViewHolder,ItemDecorator,LayoutManager,SmothScroller以及 ...
- Android动画系列 - PropertyAnim 详解
前言:上一篇文章传统View动画与Property动画基础及比较简单对Android动画系统的基础做了介绍,本篇文章将对PropertyAnimation进行全面深入的探讨,本篇文章可以分为两大块,从 ...
随机推荐
- JDBC连接数据库和释放连接
用久了hibernate现在对于JDBC是怎么实现数据库的连接和释放,所以特地总结下关于JDBC的知识,目的是用于提醒自己很多Java的基础知识需要健全. package com.ssh.action ...
- cocos2dx的发展的例子2048(加入动画版)
网上找了很多写作教程2048.只是不知道卡的移动动画,我写了一个完美的动画版少. 开发步骤: 1,一个设计CardSprite类. 2,设计主游戏场景GameScene,实现游戏逻辑,加入动画逻辑. ...
- D3js-堆栈图
效果图: 源码: <%@ page language="java" import="java.util.*" pageEncoding="UTF ...
- Add/Remove listview web part in publish site via powershell
1. Here is the code: Add WebPart in Publish Site Example : AddWebPartPublish http://localhost " ...
- MVC Razor视图引擎控件
0.日期转化
- 重新想象 Windows 8 Store Apps (2) - 控件之按钮控件: Button, HyperlinkButton, RepeatButton, ToggleButton, RadioButton, CheckBox, ToggleSwitch
原文:重新想象 Windows 8 Store Apps (2) - 控件之按钮控件: Button, HyperlinkButton, RepeatButton, ToggleButton, Rad ...
- IIS在W7下使用
1.0.发布程序
- 详细说明XML分解(两)—DOM4J
第一部分关于博客XML三接口,同时也为学习DOM4J该分析工具做准备.一般解析器基本上都实现了DOM和SAX这两组接口,DOM4J自然也不例外..DOM4J仅仅是经常使用解析器的当中一种,只是既然是实 ...
- 《深入了解mybatis原则》 MyBatis架构设计和案例研究
MyBatis这是现在很流行ORM框架,这是非常强大.事实上现却比較简单.优雅. 本文主要讲述MyBatis的架构设计思路,而且讨论MyBatis的几个核心部件.然后结合一个select查询实例.深入 ...
- 使用 Cordova+Visual Studio 创建跨平台移动应用(1)
1简介 本章节是关于Visual Studio Tools for Apache Cordova的,目前此产品只发布了预览版.Visual Studio for Apache Cordova帮助熟悉V ...