LoginSignup
0
2

More than 1 year has passed since last update.

k3sにNginxのpodを立てる

Last updated at Posted at 2023-01-16

k3sを使ったNginxのpodの立て方

今回,Nginxのリバースプロキシサーバを立てる機会があったため,その手順をここに記す.

k3sのインストール

初めに,podを立てるための土台となるk3sをインストールする.これにはk3sが提供するインストレーションスクリプトを次のように実行する.

$ curl -sfL https://get.k3s.io | sh -

正常にインストール出来れば次のようなkubectlコマンドが通る.

$ sudo kubectl get nodes
NAME          STATUS   ROLES                  AGE     VERSION

helmの準備

helmのインストールを行う.helmもインストレーションスプリクトが存在するため,これを実行する.

$ curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash

次にhelmのレポジトリを追加する.今回レポジトリ名はmy-repoとした.

$ helm repo add my-repo https://charts.bitnami.com/bitnami

Nginxのpodをインストール

以下を実行し,helmを使用してNginxをインストールする.

$ helm install my-release my-repo/nginx

podを立てる

最後にpodの立ち上げを行う.

$ helm upgrade my-release my-repo/nginx -f nginx-values.yaml

以下のような応答が返ってくれば正常に立てることが出来ている.

Release "my-release" has been upgraded. Happy Helming!
NAME: my-release
LAST DEPLOYED: Mon Jan 16 10:46:57 2023
NAMESPACE: default
STATUS: deployed
REVISION: 2
TEST SUITE: None
NOTES:
CHART NAME: nginx
CHART VERSION: 13.2.21
APP VERSION: 1.23.3

** Please be patient while the chart is being deployed **
NGINX can be accessed through the following DNS name from within your cluster:

    my-release-nginx.default.svc.cluster.local (port 80)

To access NGINX from outside the cluster, follow the steps below:

1. Get the NGINX URL by running these commands:

  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        Watch the status with: 'kubectl get svc --namespace default -w my-release-nginx'

    export SERVICE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].port}" services my-release-nginx)
    export SERVICE_IP=$(kubectl get svc --namespace default my-release-nginx -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
    echo "http://${SERVICE_IP}:${SERVICE_PORT}"

参照

K3s のインストール手順 | hassiweb's memo - GitLab

NGINX Open Source packaged by Bitnami - GitHub

0
2
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
0
2