Public Repository

Last pushed: 7 months ago
Short Description
Tomcat image for Chapter 1
Full Description

Tomcat image for 《Kubernetes权威指南》 Chapter 1

tag v2 is for rolling-update test, the webpage is updated.

There are 2 ways to make tomcat-app connect to mysql successfully:
1. Use Env "MYSQL_SERVICE_HOST" to connect to mysql service
Prerequisite: create mysql service first
tomcat-app.yaml (note: no env spec):

apiVersion: v1
kind: ReplicationController
metadata:
  name: myweb
spec:
  replicas: 1
  selector:
    app: myweb
  template:
    metadata:
      labels:
        app: myweb
    spec:
      containers:
        - name: myweb
          image: kubeguide/tomcat-app:v1
          ports:
          - containerPort: 8080

2. use service name "mysql" to connect to mysql service
Prerequisite: kubernetes dns (skydns or dnsmasq) must be installed and running successfully.
Change tomcat-app.yaml, specify env MYSQL_SERVICE_HOST=mysql

apiVersion: v1
kind: ReplicationController
metadata:
  name: myweb
spec:
  replicas: 5
  selector:
    app: myweb
  template:
    metadata:
      labels:
        app: myweb
    spec:
      containers:
        - name: myweb
          image: kubeguide/tomcat-app:v1
          ports:
          - containerPort: 8080
          env:
          - name: MYSQL_SERVICE_HOST
            value: 'mysql'
Docker Pull Command
Owner
kubeguide

Comments (7)
zack253
a month ago

这个书里面原先写的有一个问题就是说但在这里他给说明了:
首先我们只能选择其中的一个service 方式 进行使用 :
要么使用 MYSQL_SERVICE_HOST 这个 要么使用 MYSQL_SERVICE_HOST
不可以同时出现在你的rc.yaml文件中
另外 对于最新版的kubernates app 的属性需要改成name

kubeguide
2 months ago

updated description of how to connect to "mysql" service

lile
3 months ago

使用V2的镜像,按照书中的例子,访问web页面也报错:
Error:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

yaochong
4 months ago

使用V1的镜像,按照第二版书中的例子,部署,发现访问web页面出现如下错误:
Error:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

gerome
4 months ago

Can anyone share the source code of this image in github?

beyondjjw
4 months ago

docker pull kubeguide/tomcat-app:v2 就可以

liyingchunvip
6 months ago

docker pull kubeguide/tomcat-app 会转到docker.io这个网站去下载,还请修正一下地址