Skip to content

Commit

Permalink
Add kubespy trace example
Browse files Browse the repository at this point in the history
  • Loading branch information
hausdorff committed Sep 25, 2018
1 parent 47285b0 commit c463b70
Show file tree
Hide file tree
Showing 15 changed files with 1,467 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/trivial-service-trace-example/.gitignore
@@ -0,0 +1,2 @@
/bin/
/node_modules/
4 changes: 4 additions & 0 deletions examples/trivial-service-trace-example/Pulumi.yaml
@@ -0,0 +1,4 @@
name: trivial-nginx
runtime: nodejs
description: Basic example of an Kubernetes sample based on \
https://kubernetes.io/docs/user-guide/walkthrough/
48 changes: 48 additions & 0 deletions examples/trivial-service-trace-example/README.md
@@ -0,0 +1,48 @@
# Example: What happens when a `Service` starts?

In this example, we:

- Install a `Deployment` replicating an `nginx` `Pod` 3 times in a Kubernetes cluster.
- Install a `Service` exposing those `nginx` `Pod`s to the Internet.
- Use `kubespy trace` to watch what happens to that `Pod` as it starts.

You'll need:

- **Access to a Kubernetes cluster.** If you are using Pulumi, you can
trivially boot an
[GKE](https://github.com/pulumi/examples/tree/master/gcp-ts-gke),
[AKS](https://github.com/pulumi/examples/tree/master/azure-ts-aks-mean), or
[EKS](https://github.com/pulumi/examples/tree/master/aws-ts-eks) cluster.
**NOTE:** If you use [minikube](https://github.com/kubernetes/minikube),
you'll need to change the `Service`'s type to be `ClusterIP`, as minikube
does not support type `LoadBalancer`.
- **Either the Pulumi CLI or `kubectl`.** There is nothing Pulumi-specific in
this example, so you can use `kubectl`, but we hope you'll give Pulumi a
shot! The CLI installation instructions
[here](https://pulumi.io/quickstart/install.html). Pulumi works anywhere
`kubectl` works (i.e., anywhere you have a kubeconfig file), so it should
"just work" if you already have a Kubernetes cluster running.
- **`kubespy`.** Installation is a handful of commands, which you can find in the [README](https://github.com/pulumi/kubespy#installation).

Once these are complete, you'll want to do two things:

1. **Run `kubespy`.** Once you've installed it, this should be as simple as
`kubespy status v1 Pod nginx`. `kubespy` will dutifully wait for you to
deploy a `Pod` called `nginx` to your cluster.
2. **Run the example.** `kubespy` repository contains a tiny example Pod that
deploys an NGINX container.

```sh
# With Pulumi CLI.
$ git clone git@github.com:pulumi/kubespy.git
$ cd kubespy/examples/trivial-service-trace-example
$ npm install
$ pulumi up

# With kubectl.
kubectl create -f https://github.com/pulumi/kubespy/raw/master/examples/trivial-service-trace-example/yaml/nginx.yaml
```

Once done, running `kubespy trace service nginx` should display something like this:

![Changes](../../images/trace/trace-success.gif "Changes a Service undergoes as it starts, in real time")
6 changes: 6 additions & 0 deletions examples/trivial-service-trace-example/index.ts
@@ -0,0 +1,6 @@
// Copyright 2016-2018, Pulumi Corporation. All rights reserved.

import * as k8s from "@pulumi/kubernetes";

// Create an nginx pod
let nginx = new k8s.yaml.ConfigFile("yaml/nginx.yaml");

0 comments on commit c463b70

Please sign in to comment.