4
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

k8sリソースをgitlabで一元管理するためgitopsツール導入環境構築自分用メモ

Last updated at Posted at 2020-01-15

まずはGitLabについておさらい

初心者の初心者による初心者のためのGit入門
https://qiita.com/novl/items/5491b4bb87170aa58a2e

k8sはdockerの為にあるのでまずはdockerを抑えよう

Dockerのすべてが5分でわかるまとめ!(コマンド一覧付き)
https://paiza.hatenablog.com/entry/docker_intro

Docker入門(第五回)〜コンテナ間通信〜
https://knowledge.sakura.ad.jp/16082/

現役エンジニアが選ぶ、Docker初心者の勉強におすすめな本5選
https://www.yoshi-makasero.com/entry/docker-book

kubernetes dockerで作ったコンテナを拡張するk8sについておさらい

k8sはコマンドに加えマニフェスト種類など抑えるべき知識範囲がかなり広い

k8s公式ドキュメント
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands

今こそ始めよう! Kubernetes入門
https://thinkit.co.jp/series/7342

kubernetesによるDockerコンテナ管理入門
https://knowledge.sakura.ad.jp/3681/

Kubernetesを始めよう!
https://inside.dmm.com/entry/2018/04/13/hello-kubernetes

ブラウザ上で手軽に学習できるKatacodaが面白い
https://blog.a-1.dev/post/2019-05-04-katacoda/

下記から実践に入る。
gitops環境構築する前の条件として、
docker、k8sはインストールされていること。
下記の記事でk8s環境を作ろう。

なかったら最初からk8s環境を揃えてくれてるgcpサービスのgkeを使おう!


①GitLabサーバの構築

GitLab をインストールしよう! (omnibus package)
https://qiita.com/masakura/items/0a0f00dfdddc8ce27f29

面倒なので導入Shell(AWS)を作ってみました。

install_gitlab.sh
# !bin/sh
# sshサーバの導入・許可・開始
sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
# ファイアウォールの導入・許可・開始
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld

# メールサーバの導入・許可・開始
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix

echo sleep
sleep 10
# gitlab最新パッケージダウンロード
curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

# gitlabインストール
sudo yum install gitlab-ce


起動・停止・再起動
sudo gitlab-ctl start
sudo gitlab-ctl stop
sudo gitlab-ctl restart

設定ファイルはここ!
vim /etc/gitlab/gitlab.rb

設定を変更したら忘れずに!
sudo gitlab-ctl reconfigure

gitlabのインフォメーション確認
gitlab-rake gitlab:env:info

gitlabの状態確認
gitlab-ctl status
gitlab-ctl tail

アンインストール
sudo yum remove gitlab-ce


・ArgoCDの導入

ArgoCDリソースファイル
https://github.com/argoproj/argo-cd/releases

ArgoCDドキュメント(Argo CD - Declarative GitOps CD for Kubernetes)
https://argoproj.github.io/argo-cd/operator-manual/declarative-setup/

ArgoCD 擬似的webページ(GUI)
https://cd.apps.argoproj.io/

手順をshell化してみました。

install_argocd.sh
# !bin/sh
eksctl version
kubectl create namespace argocd
curl -O https://raw.githubusercontent.com/argoproj/argo-cd/v1.0.0/manifests/install.yaml
kubectl -n argocd apply -f install.yaml
"kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-server -o name | cut -d'/' -f 2
"
kubectl get service -n argocd
kubectl get deploy -n argocd
kubectl port-forward svc/argocd-server -n argocd 8080:443
kubectl get service argocd-server -n argocd
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
kubectl get service argocd-server -n argocd

・sealed-secretの導入

sealed-secretsリソースファイル
https://github.com/bitnami-labs/sealed-secrets

SecretをGitHubに登録したくないのでSealedSecretを使う
https://qiita.com/sotoiwa/items/3cd9ba7b7175ce9c71be

Kubernetes 上に Drone + Argo CD + Sealed Secrets で SlackBot の GitOps
https://qiita.com/kanatakita/items/ba55bd323d34d55d9c8d


GCPのgkeからgitops環境環境作る参考記事

gitops環境作りたいだけなら下記のハンズオンのほうが学習に無駄がないかもしれない。

EKSでArgo CDのチュートリアルを試してみた
https://dev.classmethod.jp/cloud/aws/eks-argocd-getting-started/

Argo CDによってGKEでGitOpsをする
https://www.1915keke.com/entry/2018/12/15/034843

GKEでArgoCDを使ってGitOpsしてみた
https://qiita.com/ttr_tkmkb/items/ff4d88f3a91db982b0ab


4
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?