lables - rc - rs - deployments

This commit is contained in:
Pamir Erdem
2018-09-10 23:49:25 +03:00
parent 753628c40a
commit 1af12da9e1
16 changed files with 196 additions and 41 deletions

View File

@@ -0,0 +1,7 @@
apiVersion: v1
kind: ResourceQuota
metadata:
name: quota
spec:
hard:
pods: "2"

View File

@@ -10,7 +10,7 @@ spec:
volumes:
- name: "kuard-data"
hostPath:
path: /var/lib/kuard
path: /var/lib
containers:
- image: gcr.io/kuar-demo/kuard-amd64:1
imagePullPolicy: IfNotPresent
@@ -31,4 +31,4 @@ spec:
protocol: TCP
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: OnFailure
restartPolicy: OnFailure

22
01-pods/pvc-pod.yaml Normal file
View File

@@ -0,0 +1,22 @@
apiVersion: v1
kind: Pod
metadata:
name: my-site
spec:
containers:
- name: mysql
image: mysql
volumeMounts:
- mountPath: /var/lib/mysql
name: site-data
subPath: mysql
- name: php
image: php
volumeMounts:
- mountPath: /var/www/html
name: site-data
subPath: html
volumes:
- name: site-data
persistentVolumeClaim:
claimName: my-site-data

View File

@@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: cassandra-0
spec:
storageClassName: ""
capacity:
storage: 10G
accessModes:
- ReadWriteOnce
gcePersistentDisk:
pdName: cassandra-disk
fsType: ext4

View File

@@ -1,15 +1,10 @@
apiVersion: apps/v1
apiVersion: "apps/v1beta1"
kind: StatefulSet
metadata:
name: cassandra
labels:
app: cassandra
spec:
serviceName: cassandra
replicas: 3
selector:
matchLabels:
app: cassandra
template:
metadata:
labels:
@@ -82,18 +77,8 @@ spec:
volumeClaimTemplates:
- metadata:
name: cassandra-data
annotations:
volume.beta.kubernetes.io/storage-class: fast
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: fast
provisioner: k8s.io/minikube-hostpath
parameters:
type: pd-ssd
storage: 10Gi

View File

@@ -0,0 +1,32 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kuard-deployment
spec:
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
template:
metadata:
labels:
app: kuard
version: 1.0.0
spec:
containers:
- name: kuard
image: gcr.io/kuar-demo/kuard-amd64:2
resources:
requests:
memory: "1024Mi"
cpu: "1000m"
limits:
memory: "1024Mi"
cpu: "1000m"
ports:
- containerPort: 8080
name: http
protocol: TCP

BIN
04-labels/.Readme.md.swp Normal file

Binary file not shown.

View File

@@ -3,21 +3,21 @@ kind: Deployment
metadata:
creationTimestamp: null
labels:
appVersion: 1.0.0
env: prod
appVersion: 2.0.0
konu: meetup
name: kuard
spec:
replicas: 2
selector:
matchLabels:
appVersion: 1.0.0
appVersion: 2.0.0
env: prod
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
appVersion: 1.0.0
appVersion: 2.0.0
env: prod
spec:
containers:

View File

@@ -1,5 +1,20 @@
kubectl apply -f 1_kuard.yaml </br>
kubectl get pods --show-labels </br>
kubectl get pods -l appVersion=0.0.1 </br>
kubectl get pods -l appVersion=1.0.0
kubectl get pods -l appVersion=1.0.0 </br>
kubectl get pods --all-namespaces -l appVersion!=1.0.0,app=prometheus </br>
kubectl get pods --all-namespaces -l "k8s-app in(heapster,kube-state-metrics)" </br>
kubectl get pods --all-namespaces -l "k8s-app notin(heapster,kube-state-metrics)" </br>
kubectl get pods --all-namespaces -l "k8s-app,k8s-app notin(heapster,kube-state-metrics)" </br>
kubectl get pods --field-selector=status.phase!=Running --all-namespaces </br>
kubectl get pods -o json | jq ".items[].status.containerStatuses[].name" </br>
kubectl port-forward $(kubectl get pods -o jsonpath={.items[0].metadata.name}) 8080:8080 </br>
kubectl port-forward $(kubectl get podselector=weave-scope-component=app -o jsonpath={.items..metadata.name}) 4040 </br>
#Modifying patch / labels / annotations when to restart
kubectl label nodes gke-prometheus-demo-default-pool-f423e0de-knrv konu=meetup </br>
kubectl patch deployment kuard -p '{"metadata": {"labels": {"version":"0.0.3"}}}' </br>
kubectl patch deployment kuard -p '"spec": {"template":{"metadata":{"labels":{"version":"2.0.0"}}}}' </br>
kubectl annotate deployment kuard durum=iyi </br>

1
05-configmaps/apikey.txt Normal file
View File

@@ -0,0 +1 @@
Pamir

View File

@@ -0,0 +1,8 @@
apiVersion: v1
data:
log.enabled: "1"
log.type: "debug"
log.location: "file"
kind: ConfigMap
metadata:
name: logging

View File

@@ -0,0 +1,24 @@
apiVersion: v1
kind: Pod
metadata:
name: configpod
spec:
containers:
- name: config-pod
image: nginx
env:
- name: LOG_LOCATION
valueFrom:
configMapKeyRef:
name: logging
key: log.location
- name: LOGGING_TYPE
valueFrom:
configMapKeyRef:
name: logging
key: log.type
- name: LOGGING_ENABLED
valueFrom:
configMapKeyRef:
name: logging
key: log.enabled

View File

@@ -1,17 +0,0 @@
apiVersion: v1
data:
log4j.xml: "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n<!DOCTYPE log4j:configuration
SYSTEM \"log4j.dtd\">\r\n<log4j:configuration debug=\"true\"\r\n\txmlns:log4j='http://jakarta.apache.org/log4j/'>\r\n\r\n\t<appender
name=\"console\" class=\"org.apache.log4j.ConsoleAppender\">\r\n\t <layout
class=\"org.apache.log4j.PatternLayout\">\r\n\t\t<param name=\"ConversionPattern\"\r\n\t\t
\ value=\"%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n\" />\r\n\t </layout>\r\n\t</appender>\r\n\r\n\t<root>\r\n\t\t<level
value=\"DEBUG\" />\r\n\t\t<appender-ref ref=\"console\" />\r\n\t</root>\r\n\r\n</log4j:configuration>"
my-config.txt: "name=pamir\r\nsurname=erdem\r\nbestfriend=nazli"
kind: ConfigMap
metadata:
creationTimestamp: 2017-12-23T16:20:54Z
name: my-config
namespace: default
resourceVersion: "346218"
selfLink: /api/v1/namespaces/default/configmaps/my-config
uid: 3fbdac81-e7fd-11e7-a281-08002754b872

View File

@@ -0,0 +1,23 @@
apiVersion: v1
kind: Pod
metadata:
labels:
app: guestbook
tier: frontend
name: frontend-pamir
spec:
containers:
- env:
- name: GET_HOSTS_FROM
value: dns
image: gcr.io/google_samples/gb-frontend:v3
imagePullPolicy: IfNotPresent
name: php-redis
ports:
- containerPort: 80
protocol: TCP
resources:
requests:
cpu: 100m
memory: 100Mi
dnsPolicy: ClusterFirst

View File

@@ -0,0 +1,38 @@
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: frontend
labels:
app: guestbook
tier: frontend
spec:
# modify replicas according to your case
replicas: 3
selector:
#matchLabels:
# tier: frontend
matchExpressions:
- {key: tier, operator: In, values: [frontend]}
template:
metadata:
labels:
app: guestbook
tier: frontend
spec:
containers:
- name: php-redis
image: gcr.io/google_samples/gb-frontend:v3
resources:
requests:
cpu: 100m
memory: 100Mi
env:
- name: GET_HOSTS_FROM
value: dns
# 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: 80

4
05-deployments/ReadMe Normal file
View File

@@ -0,0 +1,4 @@
kubectl apply -f 02-replicationset.yaml
kubectl get events -w
kubectl get rs -w
kubectl apply -f 02-1.rs-pod.yaml