0
0

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 1 year has passed since last update.

Sock ShopのPodを複数VMに分散させる

今回はSock Shopを1つのVMで動かすのではなく,複数のVMで動かすのが目標です.

今回はRKE2でクラスターを構築しSock Shopをインストールしました.
RKE2クラスターはこちらを参考にしました↓

名称未設定ファイル.png

上図のようなクラスターを構築しました.Worker1と2にSock Shopをたてます.3には監視ソフトなどをインストールする予定です.

Worker1と2にSock ShopのPodがたてられて欲しいのですが,このままインストールしても思うようにはいきません.

なのでnodelabelを付与し,Sock Shopのyamlファイルに追記をします.

sock-shopというラベルを付与しました.

kubectl label nodes <worker1> worker=sock-shop

yamlファイルにはnodeSelector:を用いてラベルからPodをたてるnodeを指定します.

complete-demo.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: carts
  labels:
    name: carts
  namespace: sock-shop
spec:
  replicas: 1
  selector:
    matchLabels:
      name: carts
  template:
    metadata:
      labels:
        name: carts
    spec:
      containers:
      - name: carts
      .
      .
      .
      volumes:
        - name: tmp-volume
          emptyDir:
            medium: Memory
      nodeSelector:
        worker: sock-shop

すべてのDeploymentnodeSelector:を追記しインストールします.

NAME                            READY   STATUS    RESTARTS   AGE   IP            NODE        NOMINATED NODE   READINESS GATES
carts-7fb7b76dc-j6mbd           1/1     Running   0          9d    10.42.3.108   worker2   <none>           <none>
carts-db-74ffbdb8c6-95jzt       1/1     Running   0          9d    10.42.3.110   worker2   <none>           <none>
catalogue-8b7bf47bd-ztr5h       1/1     Running   0          9d    10.42.3.109   worker2   <none>           <none>
catalogue-db-6d4b48d5d5-td62c   1/1     Running   0          9d    10.42.3.112   worker2   <none>           <none>
front-end-7d4c894c5c-tdp4d      1/1     Running   0          9d    10.42.1.69    worker1   <none>           <none>
orders-7786c965cc-mn4zp         1/1     Running   0          9d    10.42.3.111   worker2   <none>           <none>
orders-db-6c787d4bb8-x8lkg      1/1     Running   0          9d    10.42.1.70    worker1   <none>           <none>
payment-54f95cb795-xr4pq        1/1     Running   0          9d    10.42.3.113   worker2   <none>           <none>
queue-master-6988cd4ff6-r25p8   1/1     Running   0          9d    10.42.3.114   worker2   <none>           <none>
rabbitmq-857f4995c5-9nk4g       2/2     Running   0          9d    10.42.1.71    worker1   <none>           <none>
session-db-64746f5b79-k8nt8     1/1     Running   0          9d    10.42.3.115   worker2   <none>           <none>
shipping-7476449c85-28x8p       1/1     Running   0          9d    10.42.1.72    worker1   <none>           <none>
user-7f7454894f-2q8qn           1/1     Running   0          9d    10.42.3.116   worker2   <none>           <none>
user-db-7bf76cc8dc-2mtkc        1/1     Running   0          9d    10.42.3.117   worker2   <none>           <none>

無事Worker1と2にたてることができました!
このやり方だとlabelに対してランダムに振り分けているのでしょうか?Podの分散させかたも考えて振り分けないといけなさそうですね.

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?