Skip to content

Instantly share code, notes, and snippets.

@danehans
Created March 3, 2016 07:06
Show Gist options
  • Select an option

  • Save danehans/6f867cb16956de0dbe07 to your computer and use it in GitHub Desktop.

Select an option

Save danehans/6f867cb16956de0dbe07 to your computer and use it in GitHub Desktop.
gemini_vss_deploy_verification
# Ansible completes the playbook
....
PLAY RECAP ********************************************************************
172.22.111.161 : ok=296 changed=59 unreachable=0 failed=0
# SSH into the deployed node
[root@gemini ansible]# ssh [email protected]
Last login: Thu Mar 3 06:48:48 2016 from 172.22.111.248
CoreOS stable (926.0.0)
Update Strategy: No Reboots
Failed Units: 1
update-engine-stub.service
# Verify that nodes have registered with the master
core@localhost ~ $ kubectl get nodes
NAME LABELS STATUS AGE
172.22.111.161 kubernetes.io/hostname=172.22.111.161 Ready 27s
# Create a test web-app manifest (consisting of a Kubernetes replication controller and service)
core@localhost ~ $ vim web-app.yml
core@localhost ~ $ cat web-app.yml
apiVersion: v1
kind: Service
metadata:
labels:
name: web
role: service
name: web
spec:
type: NodePort
ports:
# the port that this service should serve on
- name: web
nodePort: 30302
port: 80
protocol: TCP
selector:
web: "true"
---
apiVersion: v1
kind: ReplicationController
metadata:
name: web
spec:
replicas: 1
selector:
web: "true"
template:
metadata:
labels:
name: web
web: "true"
role: web
spec:
containers:
- name: web
image: larsks/mini-httpd
env:
- name: WEB
value: "true"
ports:
- containerPort: 80
# Deploy the test web-app to the Kubernetes cluster
# Note: The web-app service is being exposed externally using a NodePort.
# That means the to access the service, you use the IP address of the node that hosts the service (172.22.111.161)
# and a port (30302) specified in the above manifest.
core@localhost ~ $ sudo kubectl create -f web-app.yml
You have exposed your service on an external port on all nodes in your
cluster. If you want to expose this service to the external internet, you may
need to set up firewall rules for the service port(s) (tcp:30302) to serve traffic.
See http://releases.k8s.io/release-1.1/docs/user-guide/services-firewalls.md for more details.
service "web" created
replicationcontroller "web" created
# Get the status of the web-app rc/pod/svc
core@localhost ~ $ kubectl get rc,pod,svc
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS AGE
web web larsks/mini-httpd web=true 1 43s
NAME READY STATUS RESTARTS AGE
web-fbngk 1/1 Running 0 43s
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
kubernetes 10.254.0.1 <none> 443/TCP <none> 5m
web 10.254.48.68 nodes 80/TCP web=true 43s
# In addition to the NodePort being used to externally expose the web-app service,
# a cluster IP (10.254.48.68) is used to provide a stable internal IP address of
# the web-app service.
# Since the rc/pod/svc above looks good, lets curl the web-app service using the
# cluster (internal) IP of the service:
core@localhost ~ $ sudo curl 10.254.48.68
<!DOCTYPE html>
<html>
<head>
<title>mini_httpd on docker</title>
<style>
body {
font-family: Arial,Helvetica Neue,Helvetica,sans-serif;
}
#address {
text-align: center;
border: thin solid black;
padding: 1ex;
margin-top: 2ex;
margin-bottom: 2ex;
max-width: 40ex;
background-color: orange;
}
#address strong {
font-size: 200%;
}
</style>
</head>
<body>
<h1>Congratulations! It worked!</h1>
This page is being served by <a href="">mini_httpd</a> running under Docker.
<div id="address">
<p><strong>2.0.5.3</strong></p>
</div>
</body>
</html>
# Now lets do the same for the external service IP (i.e. the NodePort)
core@localhost ~ $ sudo curl 172.22.111.161:30302
<!DOCTYPE html>
<html>
<head>
<title>mini_httpd on docker</title>
<style>
body {
font-family: Arial,Helvetica Neue,Helvetica,sans-serif;
}
#address {
text-align: center;
border: thin solid black;
padding: 1ex;
margin-top: 2ex;
margin-bottom: 2ex;
max-width: 40ex;
background-color: orange;
}
#address strong {
font-size: 200%;
}
</style>
</head>
<body>
<h1>Congratulations! It worked!</h1>
This page is being served by <a href="">mini_httpd</a> running under Docker.
<div id="address">
<p><strong>2.0.5.3</strong></p>
</div>
</body>
</html>
# The above curl's the NodePort IP from the Kubernetes master. Since this is
# an external IP, lets test from a machine outside the cluster that has connectivity
# to the cluster. For example, from my laptop:
DANEHANS-M-G01Z:Desktop daneyonhansen$ curl 172.22.111.161:30302
<!DOCTYPE html>
<html>
<head>
<title>mini_httpd on docker</title>
<style>
body {
font-family: Arial,Helvetica Neue,Helvetica,sans-serif;
}
#address {
text-align: center;
border: thin solid black;
padding: 1ex;
margin-top: 2ex;
margin-bottom: 2ex;
max-width: 40ex;
background-color: orange;
}
#address strong {
font-size: 200%;
}
</style>
</head>
<body>
<h1>Congratulations! It worked!</h1>
This page is being served by <a href="">mini_httpd</a> running under Docker.
<div id="address">
<p><strong>2.0.5.3</strong></p>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment