Kubernetesとは?なぜ2026年も必須スキルなのか
Kubernetes(K8s)はGoogleが開発したコンテナオーケストレーションプラットフォームで、2026年現在、本番環境でのコンテナ管理のデファクトスタンダードです。AWS EKS・Google GKE・Azure AKSなど主要クラウドすべてで対応しています。
Kubernetesの主要コンポーネント
| コンポーネント | 役割 |
|---|---|
| Pod | 最小デプロイ単位。1つ以上のコンテナを含む |
| Deployment | Podのレプリカ数・ローリングアップデートを管理 |
| Service | Podへのネットワークアクセスを提供 |
| ConfigMap | 設定データをPodに注入 |
| Secret | 機密データ(APIキー等)を安全に管理 |
| Ingress | 外部HTTPトラフィックのルーティング |
| HPA | 負荷に応じた自動スケーリング |
| Namespace | リソースの論理的な分離 |
ローカル環境の構築
# minikubeでローカルK8sクラスター構築
brew install minikube kubectl
minikube start --driver=docker --memory=4096 --cpus=2
minikube status
kubectl cluster-info
# またはkind(Kubernetes in Docker)
brew install kind
kind create cluster --name dev-cluster
kubectl config use-context kind-dev-cluster
Podのデプロイ
# pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
labels:
app: nginx
environment: production
spec:
containers:
- name: nginx
image: nginx:1.25-alpine
ports:
- containerPort: 80
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 15
periodSeconds: 20
kubectl apply -f pod.yaml
kubectl get pods
kubectl describe pod nginx-pod
kubectl logs nginx-pod
Deployment:本番対応のデプロイ
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: tech-athletes-app
labels:
app: tech-athletes
spec:
replicas: 3
selector:
matchLabels:
app: tech-athletes
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
app: tech-athletes
spec:
containers:
- name: app
image: your-registry/tech-athletes:latest
ports:
- containerPort: 3000
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: app-secrets
key: database-url
- name: NODE_ENV
value: "production"
resources:
requests:
memory: "256Mi"
cpu: "100m"
limits:
memory: "512Mi"
cpu: "500m"
Service・Ingressの設定
# service.yaml
apiVersion: v1
kind: Service
metadata:
name: tech-athletes-svc
spec:
selector:
app: tech-athletes
ports:
- protocol: TCP
port: 80
targetPort: 3000
type: ClusterIP
---
# ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: tech-athletes-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
tls:
- hosts:
- tech-athletes.com
secretName: tls-secret
rules:
- host: tech-athletes.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: tech-athletes-svc
port:
number: 80
HPA(Horizontal Pod Autoscaler)で自動スケーリング
# hpa.yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: tech-athletes-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: tech-athletes-app
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 80
Helmによるパッケージ管理
# Helmインストール
brew install helm
# Helmリポジトリ追加
helm repo add stable https://charts.helm.sh/stable
helm repo add bitnami https://charts.bitnami.com/bitnami
# Nginxをインストール
helm install my-nginx bitnami/nginx
# 自前Helmチャートの構造
helm create my-app
# my-app/
# ├── Chart.yaml
# ├── values.yaml
# └── templates/
# ├── deployment.yaml
# ├── service.yaml
# └── ingress.yaml
# デプロイ
helm install my-app ./my-app -f custom-values.yaml
helm upgrade my-app ./my-app --set image.tag=v2.0.0
Kubernetes学習ロードマップ
初級(1〜2ヶ月):Pod・Deployment・Serviceの基礎、kubectlコマンド習得
中級(2〜3ヶ月):Ingress・ConfigMap・Secret・HPA・Namespace管理
上級(3〜6ヶ月):Helm・GitOps(ArgoCD)・Prometheus監視・セキュリティ設定
資格取得:CKA(Certified Kubernetes Administrator)またはCKAD(Application Developer)
まとめ
Kubernetesは現代のクラウドネイティブ開発に必須のスキルです。ローカルでminikubeを使って練習し、AWS EKSやGKEへの移行を段階的に学ぶことを推奨します。CKA資格取得を目指すことで、体系的な知識が身につきます。