1
3

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 5 years have passed since last update.

MinikubeでLocalにKubernetes環境を作るメモ

1
Last updated at Posted at 2019-03-27

Minikube はローカルに簡単に Kubernetes 環境を作るツール。
Kubernetes の雰囲気を感じることができるらしい。
https://kubernetes.io/docs/setup/minikube/

事前準備

VirtualBox Download

VMを利用するので VirtualBox を入れておく。
https://www.virtualbox.org/wiki/Downloads

brew update

brew 使うからお作法的にやっとく。

kubectl install

Kubernetes の cli ツールをインストールする。

$ brew install kubernetes-cli

Minikube install

Minikube のインストール。

$ brew cask install minikube

minikube start

VMを通してローカルにKubernetes Cluster を立ち上げる。

$ minikube start --vm-driver=virtualbox

kubectl run

docker image を指定してアプリケーションを実行する。

$ kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.10 --port=8080
deployment.apps/hello-minikube created

kubectl expose deployment

Kubernetes のサービスとして公開する。

$ kubectl expose deployment hello-minikube --type=NodePort
service/hello-minikube exposed

kubectl get pod

Pod が可動しているかを確認する。

$ kubectl get pod
NAME                              READY     STATUS    RESTARTS   AGE
hello-minikube-6fd785d459-9798m   1/1       Running   0          1m

url から pod の稼働状況を確認することもできる。

# fish 使ってるから `$` いらないね
curl (minikube service hello-minikube --url)

Hostname: hello-minikube-6fd785d459-9798m

Pod Information:
	-no pod information available-

Server values:
	server_version=nginx: 1.13.3 - lua: 10008

Request Information:
	client_address=172.17.0.1
	method=GET
	real path=/
	query=
	request_version=1.1
	request_scheme=http
	request_uri=http://192.168.99.100:8080/

Request Headers:
	accept=*/*
	host=192.168.99.100:32311
	user-agent=curl/7.54.0

Request Body:
	-no body in request-

後始末

kubectl delete service

Kubernetes から service を削除。

$ kubectl delete services hello-minikube
service "hello-minikube" deleted

kubectl delete deployment

deploy されたアプリケーションを削除。

$ kubectl delete deployment hello-minikube
deployment.extensions "hello-minikube" deleted

minikube stop

Minikube そのものを停止する。

$ minikube stop
✋  Stopping "minikube" in virtualbox ...
🛑  "minikube" stopped.

最後に

本当に雰囲気だけが伝わった。

おしまい

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?