Giter VIP home page Giter VIP logo

git-sync-example's Introduction

git-sync-example

💡 Overview

  • Kubernetes Sidecar pattern pic08

👩‍🚒 自力でGitリポジトリからの取り込みコンテナを実装する

  • contents-puller.sh
    • 指定したGitリポジトリから定期的にコンテンツを取り込む
    • リポジトリのURLは環境変数で指定
  • Dockerfile
    • Gitリポジトリからの取り込みコンテナの定義を記述
    • contents-puller.shを起動するだけのコンテナ
  • webserver.yaml
    • Sidecar Podのマニフェストファイル
    • Deployment
      • 2つのコンテナと共有ボリュームを定義
    • Service
      • 外部へ公開するためのNodePortを定義

🚀 Run

### マニフェストを適用
$ kubectl apply -f webserver.yaml

### コンポーネント一覧の取得
$ kubectl get po
NAME                         READY   STATUS    RESTARTS   AGE
webserver-6dcc867df8-qfw46   2/2     Running   0          3m25s

$ kubectl get svc
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP        29d
webserver    NodePort    10.98.144.247   <none>        80:32617/TCP   3m46s

### アクセス先のURLを取得
$ minikube service webserver --url
🏃  Starting tunnel for service webserver.
|-----------|-----------|-------------|------------------------|
| NAMESPACE |   NAME    | TARGET PORT |          URL           |
|-----------|-----------|-------------|------------------------|
| default   | webserver |             | http://127.0.0.1:53472 |
|-----------|-----------|-------------|------------------------|
http://127.0.0.1:53472
❗  Dockerドライバーをdarwin上で動かしているため、実行するにはターミナルを開く必要があります。

🌱 既存のコンテナ(git-sync)を利用する

  • git-sync.yaml
    • Sidecar Podのマニフェストファイル
    • 上で自力で実装した補助コンテナ(GitHabからコンテンツをpullしてくる役割のコンテナ)と同様の処理を行うコンテナを利用する

🚀 Run

### マニフェストを適用
$ kubectl apply -f git-sync.yaml

### コンポーネント一覧の取得
$ kubectl get po
NAME                       READY   STATUS    RESTARTS   AGE
git-sync-c65b77d57-79c52   2/2     Running   0          28s

$ kubectl get svc
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
git-sync     NodePort    10.99.127.180   <none>        80:31023/TCP   69s
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP        29d

### アクセス先のURLを取得
$ minikube service git-sync --url
🏃  Starting tunnel for service git-sync.
|-----------|----------|-------------|------------------------|
| NAMESPACE |   NAME   | TARGET PORT |          URL           |
|-----------|----------|-------------|------------------------|
| default   | git-sync |             | http://127.0.0.1:55500 |
|-----------|----------|-------------|------------------------|
http://127.0.0.1:55500
❗  Dockerドライバーをdarwin上で動かしているため、実行するにはターミナルを開く必要があります。

🔎 Monitoring

  • Prometheus:グラフ化 / ダッシュボード表示
  • Grafana:ログ分析 / データ可視化
### Build & Run
$ docker-compose up -d

### 確認
=== * 起動するDockerコンテナ * ===
$ docker ps
CONTAINER ID   IMAGE                                 COMMAND                  CREATED        STATUS         PORTS                                                                                                      NAMES
564a512039ec   prom/prometheus                       "/bin/prometheus --c…"   12 hours ago   Up 2 seconds   0.0.0.0:9090->9090/tcp                                                                                     prometheus
a0affa135a90   grafana/grafana                       "/run.sh"                12 hours ago   Up 2 seconds   0.0.0.0:3000->3000/tcp                                                                                     grafana

=== * 作成されるDockerイメージ * ===
$ docker images
REPOSITORY                                                     TAG                                                     IMAGE ID       CREATED         SIZE
prom/prometheus                                                latest                                                  a618f5685492   3 weeks ago     175MB
grafana/grafana                                                latest                                                  c9e576dccd68   2 weeks ago     198MB

=== * 作成されるDockerネットワーク * ===
$ docker network ls
NETWORK ID     NAME                     DRIVER    SCOPE
1e0c95d851fe   monitoring_default       bridge    local

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.