728x90
반응형
kubernetes에서 redis 간단 설치하기
redis.yaml 을 생성한 후 서비스 구동에 필요한 svc, configmap, pod을 정의한다.
apiVersion: v1
kind: ConfigMap
metadata:
name: redis-config
data:
redis-config: |
maxmemory 20mb
maxmemory-policy allkeys-lru
---
apiVersion: v1
kind: Service
metadata:
name: redis
labels:
app: redis
spec:
selector:
app: redis
ports:
- name: redis
protocol: TCP
port: 6379
targetPort: 6379
---
apiVersion: v1
kind: Pod
metadata:
name: redis
labels:
app: redis
spec:
containers:
- name: redis
image: redis:latest
command:
- redis-server
- "/redis-master/redis.conf"
env:
- name: MASTER
value: "true"
ports:
- containerPort: 6379
name: redis
volumeMounts:
- mountPath: /redis-master-data
name: data
- mountPath: /redis-master
name: config
volumes:
- name: data
emptyDir: {}
- name: config
configMap:
name: redis-config
items:
- key: redis-config
path: redis.conf
위의 yaml을 이용하여 kubernetes 기본 namespace인 default에 설치
$ kubectl apply -f redis.yaml
정상 구동 확인
$ kubectl get pod
NAME READY STATUS RESTARTS AGE
redis 1/1 Running 0 29m
Cluster내부에서 접속 확인을 하기 위한 busybox 설치
nc.yaml
apiVersion: v1
kind: Pod
metadata:
name: busybox
spec:
containers:
- name: busybox
image: busybox
command:
- sleep
- "3600"
imagePullPolicy: IfNotPresent
restartPolicy: Always
nc busybox도 설치
$ kubectl apply -f ncutils.yaml
Cluster 내부에서 접속 확인
$ kubectl exec -it busybox sh -- nc redis 6379
ping
+PONG
728x90
반응형
'Programming > Kubernetes' 카테고리의 다른 글
[Kubernetes] 초간단 busybox 설치 (0) | 2022.05.23 |
---|---|
[Kubernetes] command terminated with exit code 137 (0) | 2022.05.17 |
[Kubernetes][Docker] image pull ecr login (0) | 2022.05.16 |
[Kubernetes] kubelet error - part of the existing bootstrap client certificate is expired (0) | 2022.03.14 |
[Kubernets] coredns에 multiple consul dns 등록하기 (0) | 2022.02.09 |
댓글