"카타코더 k8s - Helm Package Manager"의 두 판 사이의 차이

5번째 줄: 5번째 줄:
==Install Helm==
==Install Helm==
<source lang='console'>
<source lang='console'>
master $ curl -sLO https://storage.googleapis.com/kubernetes-helm/helm-v2.8.2-linux-amd64.tar.gz
master:~$ curl -sLO https://storage.googleapis.com/kubernetes-helm/helm-v2.8.2-linux-amd64.tar.gz
master $ tar -xvf helm-v2.8.2-linux-amd64.tar.gz
master:~$ tar -xvf helm-v2.8.2-linux-amd64.tar.gz
linux-amd64/
linux-amd64/
linux-amd64/helm
linux-amd64/helm
13번째 줄: 13번째 줄:
</source>
</source>
<source lang='console'>
<source lang='console'>
master $ mv linux-amd64/helm /usr/local/bin/
master:~$ mv linux-amd64/helm /usr/local/bin/
master $ helm version --client
master:~$ helm version --client
Client: &version.Version{SemVer:"v2.8.2", GitCommit:"a80231648a1473929271764b920a8e346f6de844", GitTreeState:"clean"}</source>
Client: &version.Version{SemVer:"v2.8.2", GitCommit:"a80231648a1473929271764b920a8e346f6de844", GitTreeState:"clean"}</source>
<source lang='console'>
<source lang='console'>
master $ helm init
master:~$ helm init
Creating /root/.helm
Creating /root/.helm
Creating /root/.helm/repository
Creating /root/.helm/repository
28번째 줄: 28번째 줄:
Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com
Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com
Adding local repo with URL: http://127.0.0.1:8879/charts
Adding local repo with URL: http://127.0.0.1:8879/charts
$HELM_HOME has been configured at /root/.helm.
$HELM_HOME has been configured at /root/.helm.


Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster.
Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster.
37번째 줄: 37번째 줄:
</source>
</source>
<source lang='console'>
<source lang='console'>
master $ helm repo update
master:~$ helm repo update
Hang tight while we grab the latest from your chart repositories...
Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Skip local chart repository
46번째 줄: 46번째 줄:
==Search For Chart==
==Search For Chart==
<source lang='console'>
<source lang='console'>
master $ helm search redis
master:~$ helm search redis
NAME                                    CHART VERSION  APP VERSION    DESCRIPTION
NAME                                    CHART VERSION  APP VERSION    DESCRIPTION
stable/prometheus-redis-exporter        1.0.2          0.28.0          Prometheus exporter for Redis metrics
stable/prometheus-redis-exporter        1.0.2          0.28.0          Prometheus exporter for Redis metrics
54번째 줄: 54번째 줄:
</source>
</source>
<source lang='console'>
<source lang='console'>
master $ helm inspect stable/redis
master:~$ helm inspect stable/redis
apiVersion: v1
apiVersion: v1
appVersion: 4.0.14
appVersion: 4.0.14
140번째 줄: 140번째 줄:
==Deploy Redis==
==Deploy Redis==
<source lang='console'>
<source lang='console'>
master $ helm install stable/redis
master:~$ helm install stable/redis
NAME:  foiled-shrimp
NAME:  foiled-shrimp
LAST DEPLOYED: Sat Mar 23 19:47:33 2019
LAST DEPLOYED: Sat Mar 23 19:47:33 2019
205번째 줄: 205번째 줄:
</source>
</source>
<source lang='console'>
<source lang='console'>
master $ helm ls
master:~$ helm ls
NAME            REVISION        UPDATED                        STATUS          CHART          NAMESPACE
NAME            REVISION        UPDATED                        STATUS          CHART          NAMESPACE
foiled-shrimp  1              Sat Mar 23 19:47:33 2019        DEPLOYED        redis-6.4.3    default
foiled-shrimp  1              Sat Mar 23 19:47:33 2019        DEPLOYED        redis-6.4.3    default
212번째 줄: 212번째 줄:
==See Results==
==See Results==
<source lang='console'>
<source lang='console'>
master $ kubectl get all
master:~$ kubectl get all
NAME                                            READY    STATUS    RESTARTS  AGE
NAME                                            READY    STATUS    RESTARTS  AGE
pod/foiled-shrimp-redis-master-0                0/1      Pending  0          53s
pod/foiled-shrimp-redis-master-0                0/1      Pending  0          53s
232번째 줄: 232번째 줄:
</source>
</source>
<source lang='console'>
<source lang='console'>
master $ cat pv.yaml
master:~$ cat pv.yaml
</source>
</source>
<source lang='yaml'>
<source lang='yaml'>
278번째 줄: 278번째 줄:
</source>
</source>
<source lang='console'>
<source lang='console'>
master $ kubectl apply -f pv.yaml
master:~$ kubectl apply -f pv.yaml
persistentvolume/pv-volume1 created
persistentvolume/pv-volume1 created
persistentvolume/pv-volume2 created
persistentvolume/pv-volume2 created
284번째 줄: 284번째 줄:
</source>
</source>
<source lang='console'>
<source lang='console'>
master $ chmod 777 -R /mnt/data*
master:~$ chmod 777 -R /mnt/data*
master $ helm install --name my-release stable/redis
master:~$ helm install --name my-release stable/redis
NAME:  my-release
NAME:  my-release
LAST DEPLOYED: Sat Mar 23 19:49:13 2019
LAST DEPLOYED: Sat Mar 23 19:49:13 2019

2019년 3월 24일 (일) 04:51 판

1 개요

카타코더 Kubernetes - Helm Package Manager
카타코더 Kubernetes
# 🔗 제목
카타코더 Kubernetes/2 e
🡵 카타코더 k8s - Use Kubernetes To Manage Secrets And Passwords
🡵 카타코더 k8s - Deploy Docker Compose Files with Kompose
🡵 카타코더 k8s - Deploying from source onto Kubernetes
🡵 카타코더 k8s - Backup and Restore with Heptio Ark
🡵 카타코더 k8s - Helm Package Manager
🡵 카타코더 k8s - Installing Weave Scope on Kubernetes
🡵 카타코더 k8s - Getting Started with Kubeless

2 Install Helm

master:~$ curl -sLO https://storage.googleapis.com/kubernetes-helm/helm-v2.8.2-linux-amd64.tar.gz
master:~$ tar -xvf helm-v2.8.2-linux-amd64.tar.gz
linux-amd64/
linux-amd64/helm
linux-amd64/README.md
linux-amd64/LICENSE
master:~$ mv linux-amd64/helm /usr/local/bin/
master:~$ helm version --client
Client: &version.Version{SemVer:"v2.8.2", GitCommit:"a80231648a1473929271764b920a8e346f6de844", GitTreeState:"clean"}
master:~$ helm init
Creating /root/.helm
Creating /root/.helm/repository
Creating /root/.helm/repository/cache
Creating /root/.helm/repository/local
Creating /root/.helm/plugins
Creating /root/.helm/starters
Creating /root/.helm/cache/archive
Creating /root/.helm/repository/repositories.yaml
Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com
Adding local repo with URL: http://127.0.0.1:8879/charts
$HELM_HOME has been configured at /root/.helm.

Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster.

Please note: by default, Tiller is deployed with an insecure 'allow unauthenticated users' policy.
For more information on securing your installation see: https://docs.helm.sh/using_helm/#securing-your-helm-installation
Happy Helming!
master:~$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Successfully got an update from the "stable" chart repository
Update Complete. ⎈ Happy Helming!⎈

3 Search For Chart

master:~$ helm search redis
NAME                                    CHART VERSION   APP VERSION     DESCRIPTION
stable/prometheus-redis-exporter        1.0.2           0.28.0          Prometheus exporter for Redis metrics
stable/redis                            6.4.3           4.0.14          Open source, advanced key-value store. It is of...
stable/redis-ha                         3.3.3           5.0.3           Highly available Kubernetes implementation of R...
stable/sensu                            0.2.3           0.28            Sensu monitoring framework backed by the Redis ...
master:~$ helm inspect stable/redis
apiVersion: v1
appVersion: 4.0.14
description: Open source, advanced key-value store. It is often referred to as a data
  structure server since keys can contain strings, hashes, lists, sets and sorted
  sets.
engine: gotpl
home: http://redis.io/
icon: https://bitnami.com/assets/stacks/redis/img/redis-stack-220x234.png
keywords:
- redis
- keyvalue
- database
maintainers:
- email: containers@bitnami.com
  name: Bitnami
- email: cedric@desaintmartin.fr
  name: desaintmartin
name: redis
sources:
- https://github.com/bitnami/bitnami-docker-redis
version: 6.4.3

---
## Global Docker image parameters
## Please, note that this will override the image parameters, including dependencies, configured to use the global value
## Current available global Docker image parameters: imageRegistry and imagePullSecrets
##
# global:
#   imageRegistry: myRegistryName
#   imagePullSecrets:
#     - myRegistryKeySecretName

## Bitnami Redis image version
## ref: https://hub.docker.com/r/bitnami/redis/tags/
##
image:
  registry: docker.io
  repository: bitnami/redis
  ## Bitnami Redis image tag
  ## ref: https://github.com/bitnami/bitnami-docker-redis#supported-tags-and-respective-dockerfile-links
  ##
  tag: 4.0.14
  ## Specify a imagePullPolicy
  ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
  ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
  ##
  pullPolicy: Always
  ## Optionally specify an array of imagePullSecrets.
  ## Secrets must be manually created in the namespace.
  ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
  ##
  # pullSecrets:
  #   - myRegistryKeySecretName

## Cluster settings
cluster:
  enabled: true
  slaveCount: 1

networkPolicy:
  ## Specifies whether a NetworkPolicy should be created
  ##
  enabled: false
...
## Sysctl InitContainer
## used to perform sysctl operation to modify Kernel settings (needed sometimes to avoid warnings)
sysctlImage:
  enabled: false
  command: []
  registry: docker.io
  repository: bitnami/minideb
  tag: latest
  pullPolicy: Always
  ## Optionally specify an array of imagePullSecrets.
  ## Secrets must be manually created in the namespace.
  ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
  ##
  # pullSecrets:
  #   - myRegistryKeySecretName
  mountHostSys: false
  resources: {}

4 Deploy Redis

master:~$ helm install stable/redis
NAME:   foiled-shrimp
LAST DEPLOYED: Sat Mar 23 19:47:33 2019
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1beta2/StatefulSet
NAME                        DESIRED  CURRENT  AGE
foiled-shrimp-redis-master  1        1        0s

==> v1/Pod(related)
NAME                                        READY  STATUS             RESTARTS  AGE
foiled-shrimp-redis-slave-769765cb44-npmfd  0/1    ContainerCreating  0         0s
foiled-shrimp-redis-master-0                0/1    Pending            0         0s

==> v1/Secret
NAME                 TYPE    DATA  AGE
foiled-shrimp-redis  Opaque  1     0s

==> v1/ConfigMap
NAME                        DATA  AGE
foiled-shrimp-redis         3     0s
foiled-shrimp-redis-health  3     0s

==> v1/Service
NAME                        TYPE       CLUSTER-IP      EXTERNAL-IP  PORT(S)   AGE
foiled-shrimp-redis-master  ClusterIP  10.107.151.156  <none>       6379/TCP  0s
foiled-shrimp-redis-slave   ClusterIP  10.96.167.183   <none>       6379/TCP  0s

==> v1beta1/Deployment
NAME                       DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE
foiled-shrimp-redis-slave  1        1        1           0          0s


NOTES:
** Please be patient while the chart is being deployed **
Redis can be accessed via port 6379 on the following DNS names from within your cluster:

foiled-shrimp-redis-master.default.svc.cluster.local for read/write operations
foiled-shrimp-redis-slave.default.svc.cluster.local for read-only operations


To get your password run:

    export REDIS_PASSWORD=$(kubectl get secret --namespace default foiled-shrimp-redis -o jsonpath="{.data.redis-password}" | base64 --decode)

To connect to your Redis server:

1. Run a Redis pod that you can use as a client:

   kubectl run --namespace default foiled-shrimp-redis-client --rm --tty -i --restart='Never' \
    --env REDIS_PASSWORD=$REDIS_PASSWORD \
   --image docker.io/bitnami/redis:4.0.14 -- bash

2. Connect using the Redis CLI:
   redis-cli -h foiled-shrimp-redis-master -a $REDIS_PASSWORD
   redis-cli -h foiled-shrimp-redis-slave -a $REDIS_PASSWORD

To connect to your database from outside the cluster execute the following commands:

    kubectl port-forward --namespace default svc/foiled-shrimp-redis 6379:6379 &
    redis-cli -h 127.0.0.1 -p 6379 -a $REDIS_PASSWORD
master:~$ helm ls
NAME            REVISION        UPDATED                         STATUS          CHART           NAMESPACE
foiled-shrimp   1               Sat Mar 23 19:47:33 2019        DEPLOYED        redis-6.4.3     default

5 See Results

master:~$ kubectl get all
NAME                                             READY     STATUS    RESTARTS   AGE
pod/foiled-shrimp-redis-master-0                 0/1       Pending   0          53s
pod/foiled-shrimp-redis-slave-769765cb44-npmfd   0/1       Running   1          53s

NAME                                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
service/foiled-shrimp-redis-master   ClusterIP   10.107.151.156   <none>        6379/TCP   53s
service/foiled-shrimp-redis-slave    ClusterIP   10.96.167.183    <none>        6379/TCP   53s
service/kubernetes                   ClusterIP   10.96.0.1        <none>        443/TCP    5m

NAME                                        DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/foiled-shrimp-redis-slave   1         1         1            0           53s

NAME                                                   DESIRED   CURRENT   READY     AGE
replicaset.apps/foiled-shrimp-redis-slave-769765cb44   1         1         0         53s

NAME                                          DESIRED   CURRENT   AGE
statefulset.apps/foiled-shrimp-redis-master   1         1         53s
master:~$ cat pv.yaml
kind: PersistentVolume
apiVersion: v1
metadata:
  name: pv-volume1
  labels:
    type: local
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/mnt/data1"
---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: pv-volume2
  labels:
    type: local
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/mnt/data2"
---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: pv-volume3
  labels:
    type: local
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/mnt/data3"
master:~$ kubectl apply -f pv.yaml
persistentvolume/pv-volume1 created
persistentvolume/pv-volume2 created
persistentvolume/pv-volume3 created
master:~$ chmod 777 -R /mnt/data*
master:~$ helm install --name my-release stable/redis
NAME:   my-release
LAST DEPLOYED: Sat Mar 23 19:49:13 2019
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/ConfigMap
NAME                     DATA  AGE
my-release-redis         3     1s
my-release-redis-health  3     1s

==> v1/Service
NAME                     TYPE       CLUSTER-IP     EXTERNAL-IP  PORT(S)   AGE
my-release-redis-master  ClusterIP  10.101.33.28   <none>       6379/TCP  1s
my-release-redis-slave   ClusterIP  10.101.238.25  <none>       6379/TCP  1s

==> v1beta1/Deployment
NAME                    DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE
my-release-redis-slave  1        1        1           0          1s

==> v1beta2/StatefulSet
NAME                     DESIRED  CURRENT  AGE
my-release-redis-master  1        1        1s

==> v1/Pod(related)
NAME                                     READY  STATUS             RESTARTS  AGE
my-release-redis-slave-56f458bb55-fc2f9  0/1    ContainerCreating  0         1s
my-release-redis-master-0                0/1    ContainerCreating  0         1s

==> v1/Secret
NAME              TYPE    DATA  AGE
my-release-redis  Opaque  1     1s


NOTES:
** Please be patient while the chart is being deployed **
Redis can be accessed via port 6379 on the following DNS names from within your cluster:

my-release-redis-master.default.svc.cluster.local for read/write operations
my-release-redis-slave.default.svc.cluster.local for read-only operations


To get your password run:

    export REDIS_PASSWORD=$(kubectl get secret --namespace default my-release-redis -o jsonpath="{.data.redis-password}" | base64 --decode)

To connect to your Redis server:

1. Run a Redis pod that you can use as a client:

   kubectl run --namespace default my-release-redis-client --rm --tty -i --restart='Never' \
    --env REDIS_PASSWORD=$REDIS_PASSWORD \
   --image docker.io/bitnami/redis:4.0.14 -- bash

2. Connect using the Redis CLI:
   redis-cli -h my-release-redis-master -a $REDIS_PASSWORD
   redis-cli -h my-release-redis-slave -a $REDIS_PASSWORD

To connect to your database from outside the cluster execute the following commands:

    kubectl port-forward --namespace default svc/my-release-redis 6379:6379 &
    redis-cli -h 127.0.0.1 -p 6379 -a $REDIS_PASSWORD
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}