Kubernetes
2 min readJun 15, 2017
Requisitos
-minikube
-kubectl
-virtualBox
jenkins-deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: jenkins-slave
spec:
replicas: 1
template:
metadata:
labels:
name: jenkins-slave
spec:
containers:
- name: jenkins-slave
image: jenkins-slave
imagePullPolicy: IfNotPresent
ports:
- containerPort: 22
jenkins-service.yaml
apiVersion: v1
kind: Service
metadata:
name: jenkins-slave
spec:
type: LoadBalancer
ports:
- name: http
port: 22
targetPort: 22
selector:
name: jenkins-slave
Iniciar minikube
MacBook-Pro-de-Andres:~ kaox$ minikube start
Starting local Kubernetes cluster…
Starting VM…
SSH-ing files into VM…
Setting up certs…
Starting cluster components…
Connecting to cluster…
Setting up kubeconfig…
Kubectl is now configured to use the cluster.
MacBook-Pro-de-Andres:~ kaox$ eval $(minikube docker-env)
Kubectl
MacBook-Pro-de-Andres:k8s kaox$ kubectl create -f jenkins-deployment.yaml
deployment "jenkins-slave" created
MacBook-Pro-de-Andres:k8s kaox$ kubectl describe deployment jenkins-slave
Name: jenkins-slave
Namespace: default
CreationTimestamp: Thu, 15 Jun 2017 10:29:49 -0500
Labels: name=jenkins-slave
Annotations: deployment.kubernetes.io/revision=1
Selector: name=jenkins-slave
Replicas: 1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 1 max unavailable, 1 max surge
Pod Template:
Labels: name=jenkins-slave
Containers:
jenkins-slave:
Image: jenkins-slave
Port: 22/TCP
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
OldReplicaSets: <none>
NewReplicaSet: jenkins-slave-2908820577 (1/1 replicas created)
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
49s 49s 1 deployment-controller Normal ScalingReplicaSet Scaled up replica set jenkins-slave-2908820577 to 1
MacBook-Pro-de-Andres:k8s kaox$ kubectl get pods
NAME READY STATUS RESTARTS AGE
jenkins-slave-2908820577-7v987 1/1 Running 0 5m
MacBook-Pro-de-Andres:k8s kaox$ kubectl scale deployment jenkins-slave --replicas=3
deployment "jenkins-slave" scaled
MacBook-Pro-de-Andres:k8s kaox$ kubectl get pods
NAME READY STATUS RESTARTS AGE
jenkins-slave-2908820577-7v987 1/1 Running 0 38m
jenkins-slave-2908820577-83dk3 1/1 Running 0 7s
jenkins-slave-2908820577-x1ljs 1/1 Running 0 7s
user@k8s-master-AC381188-0:~/tmp$ kubectl expose deployment/jenkins-master --type=LoadBalancer
service "jenkins-master" exposed
user@k8s-master-AC381188-0:~/tmp$ kubectl get services
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
jenkins-master XXXXXXXXXXX XXXXXXXXXXXX 8080:32241/TCP 13m
kubernetes 10.0.0.1 <none> 443/TCP 3d
Dashboard UI
MacBook-Pro-de-Andres:k8s kaox$ kubectl proxy
Starting to serve on 127.0.0.1:8001
Acceder al browser http://localhost:8001/ui
Otro metodo alternativo
MacBook-Pro-de-Andres:k8s kaox$ minikube dashboard
Opening kubernetes dashboard in default browser...