Skip to content

Instantly share code, notes, and snippets.

@tf
Last active August 9, 2019 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tf/cf3e07c8a83f917dc21053dc152b1799 to your computer and use it in GitHub Desktop.
Save tf/cf3e07c8a83f917dc21053dc152b1799 to your computer and use it in GitHub Desktop.
apiVersion: v1
kind: Service
metadata:
name: test-client
spec:
type: ClusterIP
ports:
- port: 85
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/instance: test-client
---
apiVersion: v1
kind: Pod
metadata:
name: test-client-pod
labels:
app.kubernetes.io/instance: test-client
spec:
containers:
- image: mysql
imagePullPolicy: IfNotPresent
name: sleep
# this is just here to keep the pod alive
args:
- "sleep"
- "1000"
ports:
# Any port will do as long as it matches the service above
- containerPort: 85
name: http
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: test-mysql
labels:
app: test-mysql
spec:
type: ClusterIP
ports:
- name: mysql
port: 3306
targetPort: mysql
selector:
app: test-mysql
---
apiVersion: v1
kind: Pod
metadata:
name: test-mysql-pod
labels:
app: test-mysql
spec:
containers:
- name: test-mysql
# Using 5.7.15 fixes the issue
image: "mysql:5.7.14"
imagePullPolicy: "IfNotPresent"
env:
- name: MYSQL_ROOT_PASSWORD
value: "rootpw"
- name: MYSQL_PASSWORD
value: "pw"
- name: MYSQL_USER
value: "user"
- name: MYSQL_DATABASE
value: "somedb"
ports:
- name: mysql
containerPort: 3306
livenessProbe:
exec:
command:
- sh
- -c
- "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}"
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
readinessProbe:
exec:
command:
- sh
- -c
- "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}"
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 1
successThreshold: 1
failureThreshold: 3
volumeMounts:
- name: data
mountPath: /var/lib/mysql
volumes:
- name: data
emptyDir: {}
$ minikube start
# I cannot imagine that this is related to the problem, but
# I have the impression that the problem is not reproducible when
# the namespace has a short name.
$ kubectl create namespace hosted-application-development
# change minikube context in .kube/config to use namespace
$ kubectl apply -f client.yaml
$ kubectl apply -f mysql.yaml
# wait until mysql pod is ready
$ kubectl exec -it test-client-pod bash
# mysql -u user -ppw -h test-mysql
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading final connect information', system error: 0
command terminated with exit code 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment