Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kubernetes動かしてみた

 Kubernetes動かしてみた

2019/1/27の、相模原 Docker&Kubernetes MeetUpでの発表資料です。Kubernetesに付いて、pod、serviceの起動といった基本的な部分を説明しています。

hashimotosyuta

January 27, 2019
Tweet

More Decks by hashimotosyuta

Other Decks in Technology

Transcript

  1. Kubernetes
    動かしてみた
    hashimoto syuta
    [email protected]

    View Slide

  2. 2
    今日の内容

    View Slide

  3. 自己紹介

    View Slide

  4. 4
    橋本 修太
    • openSUSE ユーザ会で主に活動中
    • その他、小江戸 LUG などの LUG に出没
    • 最近は途上国関連のイベントにも参加
    Twitter @syuta_openSUSE
    FB: syutah
    海に出よう >

    View Slide

  5. Kubernetes とは?

    View Slide

  6. 6
    Kubernetes
    •コンテナの実行を管理
    ‒コンテナを動かす
    ‒スケールアウト
    ‒自動再起動

    View Slide

  7. 7
    Kubernetes で出来ないこと
    •イメージの作成
    •イメージの管理
    イメージとコンテナについてはこれ
    までのお話を参照してください

    View Slide

  8. 8
    ちなみに
    •イメージの作成
      → Docker 等で可能
    •イメージの管理
      → Docker Hub や
        Portus 等で可能

    View Slide

  9. 物理的な構成

    View Slide

  10. 10
    Kubernetes はクラスタ構成
    Master
    全体を管理する(管理用のコンテナが走っている)
    Node 実際にコンテナが走る
    Kubernetes クラスタ

    View Slide

  11. 11
    Kubic
    インストールすればすぐに Kubernetes クラ
    スタになるディストリビューションも存在
    インストール方法の
    記事乗ってます

    View Slide

  12. ユーザー視点

    View Slide

  13. 13
    ユーザー視点
    Node1
    Node2
    POD A
    POD A
    POD B
    POD D
    Service

    View Slide

  14. 14
    Pod & Service
    •Pod
    Kubernetes でコンテナを動かす
    時の単位
    ほぼコンテナとイコール (ただ
    し、複数コンテナを 1Pod に配置
    する事もできる)

    View Slide

  15. 15
    Pod & Service
    •Service
    pod へのアクセスを制御
    pod は Kubernetes が自動生成し
    たりするので、 IP が変わってしま
    う。そこで Service が一元管理

    View Slide

  16. Pod を作成してみよう

    View Slide

  17. 17
    Pod を作成してみよう
    $ kubectl run nginx-test --image=nginx
    あるいは
    $ kubectl apply -f nginxtest.yaml

    View Slide

  18. 18
    Pod を作成してみよう
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: nginx-deployment
    labels:
    app: nginx
    spec:
    replicas: 3
    selector:
    matchLabels:
    app: nginx
    template:
    metadata:
    labels:
    app: nginx
    spec:
    containers:
    - name: nginx
    image: nginx:1.7.9
    ports:
    - containerPort: 80
    実際の
    yaml ファイル

    View Slide

  19. 19
    Pod を作成してみよう
    deployment
    replicaset
    pod pod
    生成・管理
    生成・管理
    ローリングアップデート
    等、デプロイを管理
    pod の数 (replica) を管理
    でもって、 pod

    View Slide

  20. 20
    Pod を作成してみよう
    情報取得
    $ kubectl get deployment
    $ kubectl get replicaset
    $ kubectl get pod
    詳細情報取得
    $ kubectl describe deployment/nginx-test

    View Slide

  21. 21
    Pod を作成してみよう
    pod (コンテナ)のログ取得
    $ kubectl logs 【 pod 名】
    pod (コンテナ)に入る
    $kubectl exec -it 【 pod 名】 bash

    View Slide

  22. Service を
    作成してみよう

    View Slide

  23. 23
    Service を作成してみよう
    $ kubectl expose deployment/nginx-test
    --type=”NodePort” --port 80
    あるいは
    $ kubectl apply -f nginxtest-service.yaml

    View Slide

  24. 24
    Service を作成してみよう
    apiVersion: v1
    kind: Service
    metadata:
    name: nginx-nodeport
    spec:
    type: NodePort
    ports:
    - port: 80
    protocol: TCP
    targetPort: 80
    selector:
    app: nginx
    実際の
    yaml ファイル

    View Slide

  25. まだまだある

    View Slide

  26. 26
    Volume
    • Persistent Volume と
    Persistent Volume Claim
    • Service Catalog
    • OpenSDS

    View Slide

  27. 27
    その他のコンポーネント
    • DaemonSet
    • StatefulSet

    View Slide

  28. Questions?

    View Slide

  29. Thank you.
    Join the conversation,
    contribute & have a lot of fun!
    www.opensuse.org

    View Slide

  30. 30
    Have a Lot of Fun, and Join Us At:
    www.opensuse.org

    View Slide

  31. General Disclaimer
    This document is not to be construed as a promise by any participating organisation to develop,
    deliver, or market a product. It is not a commitment to deliver any material, code, or
    functionality, and should not be relied upon in making purchasing decisions. openSUSE makes
    no representations or warranties with respect to the contents of this document, and specifically
    disclaims any express or implied warranties of merchantability or fitness for any particular
    purpose. The development, release, and timing of features or functionality described for
    openSUSE products remains at the sole discretion of openSUSE. Further, openSUSE reserves the
    right to revise this document and to make changes to its content, at any time, without obligation
    to notify any person or entity of such revisions or changes. All openSUSE marks referenced in
    this presentation are trademarks or registered trademarks of SUSE LLC, in the United States and
    other countries. All third-party trademarks are the property of their respective owners.
    License
    This slide deck is licensed under the Creative Commons Attribution-ShareAlike 4.0
    International license. It can be shared and adapted for any purpose (even commercially) as
    long as Attribution is given and any derivative work is distributed under the same license.
    Details can be found at https://creativecommons.org/licenses/by-sa/4.0/
    Credits
    Template
    Richard Brown
    [email protected]
    Design & Inspiration
    openSUSE Design Team
    http://opensuse.github.io/branding-
    guidelines/

    View Slide