LoginSignup
1
1

More than 5 years have passed since last update.

Kubernetes上にLinux OSをコンテナとしてデプロイする

Last updated at Posted at 2018-03-19

目的

Kubernetesは構造が複雑なため、問題が発生した際に調査をするのが大変です。特に通信の問題は調査のためにいろいろなツールを使いたいです。そこで、Kubernetes上に自由に使えるOS環境を作ってみます。

検証環境
- IBM Cloud Private 2.1.0.1 (Kubernetes 1.8)

手順

CentOSの例ですが、次のようなYAMLを作ればよいです。/dev/nullをtailし続けてコンテナが終了しないようにしているところがポイントです。

pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: centos7
spec:
  containers:
    - name: centos7
      image: centos:7
      command: [ "tailf" ]
      args: [ "/dev/null" ]

適用します。

kubectl apply -f pod.yaml

Podが作成されました。

kubectl get pod centos7 -o wide

NAME      READY     STATUS    RESTARTS   AGE       IP             NODE
centos7   1/1       Running   0          8m        10.1.173.148   192.168.11.24

シェル起動で操作可能です。

kubectl exec -it centos7 bash

[root@centos7 /]# 

以上です。

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