
The project README is getting quite large mainly because of all the getting started guides embedded in the README. Create the docs/getting-started-guides directory and relocate all getting started guides. Update the README to link to each getting started guide.
3.2 KiB
Getting started on Google Compute Engine
Prerequisites
-
You need a Google Cloud Platform account with billing enabled. Visit http://cloud.google.com/console for more details.
-
Make sure you can start up a GCE VM. At least make sure you can do the Create an instance part of the GCE Quickstart.
-
You need to have the Google Storage API, and the Google Storage JSON API enabled.
-
You must have Go (version 1.2 or later) installed: www.golang.org.
-
You must have the
gcloud
components installed. -
Ensure that your
gcloud
components are up-to-date by runninggcloud components update
. -
Get the Kubernetes source:
git clone https://github.com/GoogleCloudPlatform/kubernetes.git
Setup
The setup script builds Kubernetes, then creates Google Compute Engine instances, firewall rules, and routes:
cd kubernetes
hack/dev-build-and-up.sh
The script above relies on Google Storage to deploy the software to instances running in GCE. It uses the Google Storage APIs so the "Google Cloud Storage JSON API" setting must be enabled for the project in the Google Developers Console (https://cloud.google.com/console#/project).
The instances must also be able to connect to each other using their private IP. The script uses the "default" network which should have a firewall rule called "default-allow-internal" which allows traffic on any port on the private IPs.
If this rule is missing from the default network or if you change the network being used in cluster/config-default.sh
create a new rule with the following field values:
- Source Ranges: 10.0.0.0/8
- Allowed Protocols or Port: tcp:1-65535;udp:1-65535;icmp
Running a container (simple version)
Once you have your instances up and running, the build-go.sh
script sets up
your Go workspace and builds the Go components.
The kubecfg.sh
script spins up two containers, running Nginx and with port 80 mapped to 8080:
cd kubernetes
hack/build-go.sh
cluster/kubecfg.sh -p 8080:80 run dockerfile/nginx 2 myNginx
To stop the containers:
cluster/kubecfg.sh stop myNginx
To delete the containers:
cluster/kubecfg.sh rm myNginx
Running a container (more complete version)
Assuming you've run hack/dev-build-and-up.sh
and hack/build-go.sh
:
cd kubernetes
cluster/kubecfg.sh -c api/examples/pod.json create /pods
Where pod.json contains something like:
{
"id": "php",
"kind": "Pod",
"apiVersion": "v1beta1",
"desiredState": {
"manifest": {
"version": "v1beta1",
"id": "php",
"containers": [{
"name": "nginx",
"image": "dockerfile/nginx",
"ports": [{
"containerPort": 80,
"hostPort": 8080
}],
"livenessProbe": {
"enabled": true,
"type": "http",
"initialDelaySeconds": 30,
"httpGet": {
"path": "/index.html",
"port": "8080"
}
}
}]
}
},
"labels": {
"name": "foo"
}
}
Look in api/examples/
for more examples
Tearing down the cluster
cd kubernetes
cluster/kube-down.sh