Table of Contents |
---|
Kubernetes
Kubernetes Cluster Install
Follow RKE setupĀ OOM RKE Kubernetes Deployment#Quickstart
Kubernetes Services
Storage
Volumes
https://kubernetes.io/docs/concepts/storage/volumes/
Storage Classes
https://kubernetes.io/docs/concepts/storage/storage-classes/
Persistent Volumes
Persistent Volume Claims
Gerrit
Replication
...
Code Block | ||||
---|---|---|---|---|
| ||||
ubuntu@ip-172-31-3-87:~$ sudo helm install --name mysqldb --set mysqlRootPassword=myrootpass,mysqlUser=myuser,mysqlPassword=mypass,mysqlDatqbase=mydb stable/mysq NAME: mysqldb LAST DEPLOYED: Thu Mar 21 16:06:02 2019 NAMESPACE: default STATUS: DEPLOYED RESOURCES: ==> v1/ConfigMap NAME DATA AGE mysqldb-test 1 0s ==> v1/PersistentVolumeClaim NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE mysqldb Pending 0s ==> v1/Service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE mysqldb ClusterIP 10.43.186.39 <none> 3306/TCP 0s ==> v1beta1/Deployment NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE mysqldb 1 1 1 0 0s ==> v1/Pod(related) NAME READY STATUS RESTARTS AGE mysqldb-979887bcf-4hf59 0/1 Pending 0 0s ==> v1/Secret NAME TYPE DATA AGE mysqldb Opaque 2 0s NOTES: MySQL can be accessed via port 3306 on the following DNS name from within your cluster: mysqldb.default.svc.cluster.local To get your root password run: MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace default mysqldb -o jsonpath="{.data.mysql-root-password}" | base64 --decode; echo) To connect to your database: 1. Run an Ubuntu pod that you can use as a client: kubectl run -i --tty ubuntu --image=ubuntu:16.04 --restart=Never -- bash -il 2. Install the mysql client: $ apt-get update && apt-get install mysql-client -y 3. Connect using the mysql cli, then provide your password: $ mysql -h mysqldb -p To connect to your database directly from outside the K8s cluster: MYSQL_HOST=127.0.0.1 MYSQL_PORT=3306 # Execute the following command to route the connection: kubectl port-forward svc/mysqldb 3306 mysql -h ${MYSQL_HOST} -P${MYSQL_PORT} -u root -p${MYSQL_ROOT_PASSWORD} |
DevOps
Kubernetes Cluster Install
Follow RKE setupĀ OOM RKE Kubernetes Deployment#Quickstart
Kubernetes Services
Namespaces
Create a specific namespace
https://kubernetes.io/docs/tasks/administer-cluster/namespaces-walkthrough/
Code Block | ||
---|---|---|
| ||
vi namespace-dev.json
{
"kind": "Namespace",
"apiVersion": "v1",
"metadata": {
"name": "dev",
"labels": {
"name": "dev"
}
}
}
ubuntu@ip-172-31-30-234:~/helm/book$ kubectl create -f namespace-dev.json
namespace/dev created
ubuntu@ip-172-31-30-234:~/helm/book$ kubectl get namespaces --show-labels
NAME STATUS AGE LABELS
default Active 5d <none>
dev Active 44s name=dev |
Contexts
Code Block | ||
---|---|---|
| ||
ubuntu@ip-172-31-30-234:~/helm/book$ sudo kubectl config set-context dev --namespace=dev --cluster=local --user=local
Context "dev" created.
ubuntu@ip-172-31-30-234:~/helm/book$ sudo kubectl config use-context dev
Switched to context "dev". |
Storage
Volumes
https://kubernetes.io/docs/concepts/storage/volumes/
hostPath
https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/
Code Block | ||
---|---|---|
| ||
kind: PersistentVolume
apiVersion: v1
metadata:
name: task-pv-volume
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/home/ubuntu/ltec-tools-data1"
ubuntu@ip-172-31-30-234:~/helm/book$ kubectl create -f hostpath-volume.yaml -n dev
persistentvolume/task-pv-volume created
ubuntu@ip-172-31-30-234:~/helm/book$ kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
task-pv-volume 5Gi RWO Retain Available manual 2m
|
Storage Classes
https://kubernetes.io/docs/concepts/storage/storage-classes/
Persistent Volumes
Persistent Volume Claims
Design Issues
Links
https://kubernetes.io/docs/concepts/storage/storage-classes/