K8S-gitlabのビルド

Gitlab公式には、すぐにインストールする方法ヘルムKubernetesクラスタを提供しますが、チャートパックヘルムを使用するプロセスが存在し、他の多くの追加の設定があるので、私たちはここに?自分自身である、カスタムインストールを使用していリソースマニフェストファイルを定義します。

Gitlab主に3つのアプリケーションに関連する:Redisのは、PostgreSQLは、Gitlabコアプログラムは、実際には、私たちはこれらの3つのアプリケーションが起動され、その後、Gitlab、私たちはここにミラーを使用することを選択し、対応する設定を簡単にインストールすることができます追加しますか?公式ではないが、サードパーティ製の画像の非常に大きな数で使用されるコンテナのGitlab:sameersbn/gitlab基本的には同期更新と公式アドレス:http://www.damagehead.com/docker-gitlab/

我々はRedisのか、PostgreSQLがサービスを利用することができます持っている場合は、直接配置Gitlab環境変数は、単一のデプロイメントでない場合はすることができます。

次のように最初に展開Redisのサービスは、対応するリソースマニフェストファイルを必要とします:(gitlab-redis.yaml)

apiVersion: apps/v1beta1
kind: Deployment
metadata: name: redis namespace: kube-ops labels: name: redis spec: template: metadata: name: redis labels: name: redis spec: containers: - name: redis image: sameersbn/redis imagePullPolicy: IfNotPresent ports: - name: redis containerPort: 6379 volumeMounts: - mountPath: /var/lib/redis name: data livenessProbe: exec: command: - redis-cli - ping initialDelaySeconds: 30 timeoutSeconds: 5 readinessProbe: exec: command: - redis-cli - ping initialDelaySeconds: 5 timeoutSeconds: 1 volumes: - name: data emptyDir: {} --- apiVersion: v1 kind: Service metadata: name: redis namespace: kube-ops labels: name: redis spec: ports: - name: redis port: 6379 targetPort: redis selector: name: redis 

その後、リソースマニフェストファイルを対応するデータベースPostgreSQLは、次のように:(gitlab-postgresql.yaml)

apiVersion: apps/v1beta1
kind: Deployment
metadata: name: postgresql namespace: kube-ops labels: name: postgresql spec: template: metadata: name: postgresql labels: name: postgresql spec: containers: - name: postgresql image: sameersbn/postgresql:10 imagePullPolicy: IfNotPresent env: - name: DB_USER value: gitlab - name: DB_PASS value: passw0rd - name: DB_NAME value: gitlab_production - name: DB_EXTENSION value: pg_trgm ports: - name: postgres containerPort: 5432 volumeMounts: - mountPath: /var/lib/postgresql name: data livenessProbe: exec: command: - pg_isready - -h - localhost - -U - postgres initialDelaySeconds: 30 timeoutSeconds: 5 readinessProbe: exec: command: - pg_isready - -h - localhost - -U - postgres initialDelaySeconds: 5 timeoutSeconds: 1 volumes: - name: data emptyDir: {} --- apiVersion: v1 kind: Service metadata: name: postgresql namespace: kube-ops labels: name: postgresql spec: ports: - name: postgres port: 5432 targetPort: postgres selector: name: postgresql 

?そして、私たちのGitlabアプリケーションの中核である、として対応するリソースマニフェストファイルは、以下:(gitlab.yaml)

apiVersion: apps/v1beta1
kind: Deployment
metadata: name: gitlab namespace: kube-ops labels: name: gitlab spec: template: metadata: name: gitlab labels: name: gitlab spec: containers: - name: gitlab image: sameersbn/gitlab:11.8.1 imagePullPolicy: IfNotPresent env: - name: TZ value: Asia/Shanghai - name: GITLAB_TIMEZONE value: Beijing - name: GITLAB_SECRETS_DB_KEY_BASE value: long-and-random-alpha-numeric-string - name: GITLAB_SECRETS_SECRET_KEY_BASE value: long-and-random-alpha-numeric-string - name: GITLAB_SECRETS_OTP_KEY_BASE value: long-and-random-alpha-numeric-string - name: GITLAB_ROOT_PASSWORD value: admin321 - name: GITLAB_ROOT_EMAIL value: [email protected] - name: GITLAB_HOST value: git.qikqiak.com - name: GITLAB_PORT value: "80" - name: GITLAB_SSH_PORT value: "22" - name: GITLAB_NOTIFY_ON_BROKEN_BUILDS value: "true" - name: GITLAB_NOTIFY_PUSHER value: "false" - name: GITLAB_BACKUP_SCHEDULE value: daily - name: GITLAB_BACKUP_TIME value: 01:00 - name: DB_TYPE value: postgres - name: DB_HOST value: postgresql - name: DB_PORT value: "5432" - name: DB_USER value: gitlab - name: DB_PASS value: passw0rd - name: DB_NAME value: gitlab_production - name: REDIS_HOST value: redis - name: REDIS_PORT value: "6379" ports: - name: http containerPort: 80 - name: ssh containerPort: 22 volumeMounts: - mountPath: /home/git/data name: data livenessProbe: httpGet: path: / port: 80 initialDelaySeconds: 180 timeoutSeconds: 5 readinessProbe: httpGet: path: / port: 80 initialDelaySeconds: 5 timeoutSeconds: 1 volumes: - name: data emptyDir: {} --- apiVersion: v1 kind: Service metadata: name: gitlab namespace: kube-ops labels: name: gitlab spec: ports: - name: http port: 80 targetPort: http - name: ssh port: 22 targetPort: ssh selector: name: gitlab --- apiVersion: extensions/v1beta1 kind: Ingress metadata: name: gitlab namespace: kube-ops annotations: kubernetes.io/ingress.class: traefik spec: rules: - host: git.qikqiak.com http: paths: - backend: serviceName: gitlab servicePort: http 

私達はちょうど使用し、アプリケーションデータは、データの永続化をしない?ここに注意を払う必要がありemptyDir: {}、ポッド?ハングした後、該当するデータは存在しません、あなたが正式な環境で行われなければならない永続的なデータを使用したいので、ボリュームの種類をこのようなPV / PVC又はSTORAGECLASSの追加など。

RedisのとPostgreSQL関連の環境変数の設定は、ほかに、我々はgitlabのドメイン名を設定するには、イングレスオブジェクトを追加するためにここにいるところがありますgit.qikqiak.comそのようにアプリケーションの配備が完了した後、私たちは、ドメイン名を介してアクセスすることができるようになりますと、に直接展開:

$ kubectl create -f gitlab-redis.yaml gitlab-postgresql.yaml gitlab.yaml

作成したら、ポッドの展開ステータスを表示します。

$ kubectl get pods -n kube-ops
NAME                                           READY     STATUS    RESTARTS   AGE
gitlab-7d855554cb-twh7c                        1/1       Running   0          10m
postgresql-8566bb959c-2tnvr                    1/1       Running   0          17h
redis-8446f57bdf-4v62p                         1/1       Running   0          17h

あなたは、その後、我々は、ドメイン名の進入によって定義することができ、成功に配備されている見ることができるgit.qikqiak.comポータルにアクセスするために(DNS解決が行われたり、ローカルの/ etc / hostsにマッピングを追加する必要があります):

gitlabポータルgitlabポータル

ユーザー名rootを使用して、指定されたスーパーバイザー・パスワードの展開GITLAB_ROOT_PASSWORD=admin321ホームにログインします:

gitlabホームページgitlabホームページ

Gitlab実行した後、我々はサインアップすると、新規ユーザーのためのプロジェクトを作成することができます、また、そのような?言語設定を設定するなど、他のシステムの多くを行うことができますか?その上スタイルとを適用します。

クリックしてCreate a project新しいプロジェクトを作成し、使用前のGithub上の大きな違いはありません。

gitlabプロジェクトを作成しますgitlabプロジェクトを作成します

一度作成された、我々は?追加することはできますか?ローカルユーザーをSSH-KEY、私たちはSSH経由でコードを引っ張ったり、プッシュすることができますように。SSH公開鍵は通常に含まれている~/.ssh/id_rsa.pubファイル、およびすることssh-rsaで始まります。ない場合は、使用することができますssh-keygen生成するコマンドを、id_rsa.pubSSH公開鍵の内容は、私たちが必要とするものであるの内側に、そして中Gitlabに追加します。

通常、sshのポート22がデフォルトで使用しているため、私たちサービスを通じてだけでポート22が?順序によって、マッピングされたので、今の接続にデフォルトのポート22を使用している場合、ポート22とGitlabコンテナへのマッピング方法はありませんあなたは?22ポートと、容器内のポートがノードにバインドされている必要があるので、ここで我々はNodePortによってポートマップ22 Gitlab容器の内部に行くことができますssh接続を実行するノードは、例えば、我々はに環境変数を設定するGITLAB_SSH_PORT=30022サービスのGitlabまたNodePortタイプを設定します。

apiVersion: v1
kind: Service
metadata: name: gitlab namespace: kube-ops labels: name: gitlab spec: ports: - name: http port: 80 targetPort: http - name: ssh port: 22 targetPort: ssh nodePort: 30022 type: NodePort selector: name: gitlab 

sshのポート番号を使用するときに一番上に置かれます、あなたがランダムに生成し、再び展開とアップデートサービスの下ではありませんので、更新が完了し、そして今、私たちはプロジェクト内のclone、上記対応nodePort sshのポートは30022に設定されていることに注意してください:?

gitlabのSSHgitlabのSSH

?今、あなたは使用することができClone with SSH、我々はSSH公開鍵を設定した上でので、あなたが直接倉庫の上??アクセスできるように、アドレスを?:

$ git clone ssh://[email protected]:30022/root/gitlab-demo.git
Cloning into 'gitlab-demo'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

それからちょうど次のプロジェクトでいくつかのリソースを追加します。

$ echo "# hello world" >  README.md
$ git add . $ git commit -m 'hello world' [master (root-commit) 63de7cb] hello world 1 file changed, 1 insertion(+) create mode 100644 README.md $ git push origin master Counting objects: 3, done. Writing objects: 100% (3/3), 224 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To ssh://[email protected]:30022/root/gitlab-demo.git * [new branch] master -> master 

その後、ブラウザを更新、あなただけのREADME.mdファイルより作成したGitリポジトリを見ることができます:

gitのコミット

おすすめ

転載: www.cnblogs.com/fuyuteng/p/11418734.html