Skip to content

Commit

Permalink
Merge branch 'master' into mattstratton/kubernetes-go-configmap-rollout
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstratton committed Jun 29, 2021
2 parents 95965d1 + 529c1f2 commit e53fc30
Show file tree
Hide file tree
Showing 32 changed files with 1,528 additions and 342 deletions.
1 change: 0 additions & 1 deletion .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ jobs:
- Aws
- Azure
- Gcp
- Packet
- EquinixMetal
- Cloud
dotnet-version:
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/performance_metrics_cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,8 @@ jobs:
- uses: actions/checkout@v2
- name: "Temporarily hack go.mod to get pre-release pulumi deps"
run: ./misc/test/temp_hack_go_mod.sh
# - name: Install Latest Stable Pulumi CLI
# uses: pulumi/setup-pulumi@v2
- name: Install Pulumi CLI with tracing additions (temp until Latest Stable has it)
run: |-
curl -sSL https://get.pulumi.com | bash -s -- --version 3.5.0-alpha.1623852893
echo "/home/runner/.pulumi/bin" >> $GITHUB_PATH
- name: Install Latest Stable Pulumi CLI
uses: pulumi/setup-pulumi@v2
- run: echo "Currently Pulumi $(pulumi version) is installed"
- name: Install Testing Dependencies
run: make ensure
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/run-tests-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ env:
GOOGLE_PROJECT: ${{ secrets.GCP_PROJECT_ID }}
GOOGLE_REGION: us-central1
GOOGLE_ZONE: us-central1-a
PACKET_AUTH_TOKEN: ${{ secrets.PACKET_AUTH_TOKEN }}
PR_COMMIT_SHA: ${{ github.event.client_payload.pull_request.head.sha }}
PACKET_AUTH_TOKEN: ${{ secrets.PACKET_AUTH_TOKEN }}
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
PULUMI_API: https://api.pulumi-staging.io
PULUMI_TEST_OWNER: moolumi
Expand Down Expand Up @@ -293,7 +293,6 @@ jobs:
- Aws
- Azure
- Gcp
- Packet
- EquinixMetal
- Cloud
dotnet-version:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/smoke-test-cli-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ jobs:
- Aws
- Azure
- Gcp
- Packet
- EquinixMetal
- Cloud
dotnet-version:
Expand Down
15 changes: 2 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ $ git pull origin master
- [F5](#f5)
- [Twilio](#twilio)
- [Linode](#linode)
- [Packet](#packet)
- [Testing](#testing)
- [Automation API](https://github.com/pulumi/automation-api-examples)

Expand Down Expand Up @@ -293,6 +292,8 @@ Example | Description |
--------- | --------- |
[Guestbook](kubernetes-go-guestbook) | Build and deploy a simple, multi-tier web application using Kubernetes and Docker.
[App Rollout via ConfigMap](kubernetes-go-configmap-rollout) | Enable a change in a ConfigMap to trigger a rollout of an nginx Deployment.
[Wordpress Helm Chart](kubernetes-go-helm-wordpress) | Use the Helm API to deploy v9.6.0 of the Wordpress Helm Chart to a Kubernetes cluster.
[Expose Deployment](kubernetes-go-exposed-deployment) | Deploy nginx to a Kubernetes cluster, and publicly expose it using a Kubernetes Service.

## Openstack

Expand Down Expand Up @@ -373,18 +374,6 @@ Example | Description |
--------- | --------- |
[Web Server](linode-js-webserver) | Build a web server on Linode.

## Packet

### TypeScript
Example | Description |
--------- | --------- |
[Web Server](packet-ts-webserver) | Build a web server on Packet.net.

### Python
Example | Description |
--------- | --------- |
[Web Server](packet-py-webserver) | Build a web server on Packet.net.

## Testing

Example | Description |
Expand Down
2 changes: 1 addition & 1 deletion aws-ts-static-website/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const config = {
// If true create an A record for the www subdomain of targetDomain pointing to the generated cloudfront distribution.
// If a certificate was generated it will support this subdomain.
// default: true
includeWWW: stackConfig.getBoolean("includeWWW") || true,
includeWWW: stackConfig.getBoolean("includeWWW") ?? true,
};

// contentBucket is the S3 bucket that the website's contents will be stored in.
Expand Down
3 changes: 3 additions & 0 deletions kubernetes-go-exposed-deployment/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: kubernetes-go-exposed-deployment
runtime: go
description: A minimal Go Pulumi program
97 changes: 97 additions & 0 deletions kubernetes-go-exposed-deployment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
[![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new)

# Exposing a Deployment with a Public IP Address

Deploys `nginx` to a Kubernetes cluster, and publicly exposes it to the Internet with an IP address,
using a Kubernetes `Service`.

In the gif below we see the experience of deploying this example with `pulumi up`. Notice that
Pulumi has an inherent notion of "done-ness" -- Pulumi waits for the IP address to be allocated to
the `Service`. Because this example uses the Pulumi concept of _stack exports_ to report this IP
address, in this example we are also able to use `curl` to reach the `nginx` server.

![Allocating a public IP to a Deployment](images/deploy.gif "Allocating a public IP to a Deployment")

## Running the App

If you haven't already, follow the steps in [Pulumi Installation and
Setup](https://www.pulumi.com/docs/get-started/install/) and [Configuring Pulumi
Kubernetes](https://www.pulumi.com/docs/intro/cloud-providers/kubernetes/setup/) to get setup with
Pulumi and Kubernetes.

Now, install dependencies:

```sh
go get ./...
```

Create a new stack:

```sh
$ pulumi stack init
Enter a stack name: exposed-deployment-dev
```

This example will attempt to expose the `nginx` deployment Internet with a `Service` of type
`LoadBalancer`. Since minikube does not support `LoadBalancer`, the application already knows to use
type `ClusterIP` instead; all you need to do is to tell it whether you're deploying to minikube:

```sh
pulumi config set kubernetes-go-exposed-deployment:isMinikube <value>
```

Perform the deployment:

```sh
$ pulumi up
Updating stack 'exposed-deployment-dev'
Performing changes:

Type Name Status Info
+ pulumi:pulumi:Stack exposed-deployment-exposed-deployment-dev created 1 warning
+ ├─ kubernetes:apps:Deployment nginx created
+ └─ kubernetes:core:Service nginx created 2 info messages

Diagnostics:
kubernetes:core:Service: nginx
info: ✅ Service 'nginx-rn6uipeg' successfully created endpoint objects

info: ✅ Service has been allocated an IP

---outputs:---
frontendIp: "35.226.79.225"

info: 3 changes performed:
+ 3 resources created
Update duration: 46.555593397s

Permalink: https://app.pulumi.com/hausdorff/exposed-deployment-dev/updates/1
```

We can see here in the `---outputs:---` section that Wordpress was allocated a public IP, in this
case `35.226.79.225`. It is exported with a stack output variable, `frontendIp`. We can use `curl`
and `grep` to retrieve the `<title>` of the site the proxy points at.

> _Note_: minikube does not support type `LoadBalancer`; if you are deploying to minikube, make sure
> to run `kubectl port-forward svc/frontend 8080:80` to forward the cluster port to the local
> machine and access the service via `localhost:8080`.
```sh
$ curl -sL $(pulumi stack output frontendIp) | grep "<title>"
<title>Welcome to nginx!</title>
```

## Next steps

Now that `nginx` is deployed and exposed to the internet with an IP, try playing around with the
example!

If we change the `nginx` image to `nginx:1.16-alpine`, we can run `pulumi preview --diff` and see
this change reported to us:

![Diff](images/diff.gif "Reporting a diff after we change the app")

Notice also that if you provide an image that does not exist, Pulumi will report errors as it sees
them. You should see something similar in principle to this:

![Diff](images/error.gif "Error reporting")
8 changes: 8 additions & 0 deletions kubernetes-go-exposed-deployment/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module kubernetes-go-exposed-deployment

go 1.14

require (
github.com/pulumi/pulumi/sdk/v3 v3.5.1
github.com/pulumi/pulumi-kubernetes/sdk/v3 v3.0.0
)
Loading

0 comments on commit e53fc30

Please sign in to comment.