kubernetea Labs
Lab 1 : Replicaset lab
apiVersion: apps/v1
kind: ReplicaSet
metadata:
namespace: yourname
name: frontend
labels:
app: guestbook
tier: frontend
spec:
# modify replicas according to your case
replicas: 3
selector:
matchLabels:
tier: frontend
template:
metadata:
labels:
tier: frontend
spec:
containers:
- name: php-redis
image: gcr.io/google_samples/gb-frontend:v3
Lab 2 : Create Statfulset for mySQl DB with PVC and Secret
Step 1: Create secret with password
echo -n 'devops' | base64
apiVersion: v1
kind: Secret
metadata:
namespace: yourname
name: mysql-pass
type: Opaque
data:
password: ZGV2b3Bz
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
namespace: yourname
name: mysql-pv-claim
labels:
app: wordpress
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 40Gi
apiVersion: apps/v1
kind: StatefulSet
metadata:
namespace: yourname
name: wordpress-mysql
labels:
app: wordpress
spec:
selector:
matchLabels:
app: wordpress
tier: mysql
template:
metadata:
labels:
app: wordpress
tier: mysql
spec:
containers:
- image: mysql:5.6
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-pass
key: password
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pv-claim
apiVersion: v1
kind: Service
metadata:
namespace: yourname
name: wordpress-mysql
labels:
app: wordpress
spec:
ports:
- port: 3306
selector:
app: wordpress
tier: mysql
Last updated