From 1d4d05ee610af53cbfbe94e5e592e574d0390b34 Mon Sep 17 00:00:00 2001 From: pengtao Date: Wed, 23 Mar 2022 22:27:21 +0800 Subject: [PATCH] add new test --- redis02/app02-namespace.yaml | 7 +++++ redis02/app02_redis.yaml | 51 ++++++++++++++++++++++++++++++++++++ redis02/busybox.yaml | 14 ++++++++++ redis02/config/redis.conf | 50 +++++++++++++++++++++++++++++++++++ redis02/readme.md | 47 +++++++++++++++++++++++++++++++++ 5 files changed, 169 insertions(+) create mode 100644 redis02/app02-namespace.yaml create mode 100644 redis02/app02_redis.yaml create mode 100644 redis02/busybox.yaml create mode 100644 redis02/config/redis.conf create mode 100644 redis02/readme.md diff --git a/redis02/app02-namespace.yaml b/redis02/app02-namespace.yaml new file mode 100644 index 0000000..e719ed0 --- /dev/null +++ b/redis02/app02-namespace.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: app02 + labels: + name: app02 diff --git a/redis02/app02_redis.yaml b/redis02/app02_redis.yaml new file mode 100644 index 0000000..716c698 --- /dev/null +++ b/redis02/app02_redis.yaml @@ -0,0 +1,51 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: redis-svc + namespace: app02 + labels: + app: redis +spec: + type: ClusterIP + ports: + - name: redis + port: 6379 + selector: + app: app02-redis +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: app02-redis + namespace: app02 + labels: + app: redis +spec: + replicas: 1 + selector: + matchLabels: + app: app02-redis + template: + metadata: + labels: + app: app02-redis + name: app02-redis + spec: + containers: + - name: app02-redis + image: redis + volumeMounts: + - name: redis-conf + mountPath: "/usr/local/etc" + command: + - "redis-server" + args: + - "/usr/local/etc/redis/redis.conf" + volumes: + - name: redis-conf + configMap: + name: app02-redis-conf + items: + - key: redis.conf + path: redis/redis.conf diff --git a/redis02/busybox.yaml b/redis02/busybox.yaml new file mode 100644 index 0000000..ef9fb73 --- /dev/null +++ b/redis02/busybox.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Pod +metadata: + name: test01 + labels: + app: busybox +spec: + containers: + - name: test001 + image: busybox + command: + - "ping" + args: + - "baidu.com" diff --git a/redis02/config/redis.conf b/redis02/config/redis.conf new file mode 100644 index 0000000..7b13409 --- /dev/null +++ b/redis02/config/redis.conf @@ -0,0 +1,50 @@ +#daemonize yes +pidfile /data/redis.pid +port 6379 +tcp-backlog 30000 +timeout 0 +tcp-keepalive 10 +loglevel notice +logfile /data/redis.log +databases 16 +#save 900 1 +#save 300 10 +#save 60 10000 +stop-writes-on-bgsave-error no +rdbcompression yes +rdbchecksum yes +dbfilename dump.rdb +dir /data +slave-serve-stale-data yes +slave-read-only yes +repl-diskless-sync no +repl-diskless-sync-delay 5 +repl-disable-tcp-nodelay no +slave-priority 100 +requirepass ibalife +maxclients 30000 +appendonly no +appendfilename "appendonly.aof" +appendfsync everysec +no-appendfsync-on-rewrite no +auto-aof-rewrite-percentage 100 +auto-aof-rewrite-min-size 64mb +aof-load-truncated yes +lua-time-limit 5000 +slowlog-log-slower-than 10000 +slowlog-max-len 128 +latency-monitor-threshold 0 +notify-keyspace-events KEA +hash-max-ziplist-entries 512 +hash-max-ziplist-value 64 +list-max-ziplist-entries 512 +list-max-ziplist-value 64 +set-max-intset-entries 1000 +zset-max-ziplist-entries 128 +zset-max-ziplist-value 64 +hll-sparse-max-bytes 3000 +activerehashing yes +client-output-buffer-limit normal 0 0 0 +client-output-buffer-limit slave 256mb 64mb 60 +client-output-buffer-limit pubsub 32mb 8mb 60 +hz 10 \ No newline at end of file diff --git a/redis02/readme.md b/redis02/readme.md new file mode 100644 index 0000000..4ac21a9 --- /dev/null +++ b/redis02/readme.md @@ -0,0 +1,47 @@ +create namespace + +kubectl apply -f namespace.yaml + + +# 查看 namespace +kubectl get namespace --show-labels +kubectl config view | grep namespace: +# 切换默认namespace +kubectl config current-context +kubectl config set-context test --namespace=app01 \ + --cluster=docker-desktop \ + --user=docker-desktop + +kubectl config set-context prod --namespace=production \ + --cluster=docker-desktop \ + --user=docker-desktop +kubectl config view +# 切换环境到DEV +kubectl config use-context test +# check 当前环境 +kubectl config current-context +# 查看配额 +kubectl get resourcequotas +kubectl get resourcequota app01-redis --output=yaml + +# create configmap +kubectl create configmap app01-redis-conf --from-file=redis.conf + +kubectl get configmap -n miles-app01 + +NAME DATA AGE +kube-root-ca.crt 1 3m30s +miles-app01-redis-conf 1 20s + +# 创建和查看 pod +kubectl apply -f app01_redis.yaml +kubectl get pods -n app01 + +# 注意:configMap 会挂在 /usr/local/etc/redis/redis.conf 上。与 mountPath 和 configMap 下的 path 一同指定 + +kubectl get pod miles-app01-redis-b48ff8c66-q5cv2 -n miles-app01 +kubectl run busybox --image=busybox --command -- ping baidu.com +kubectl exec -it busybox -- /bin/bash +k describe replicaset.apps/app01-redis-64847ffc48 +k get all -ALL +k describe pods \ No newline at end of file