Skip to content

Commit

Permalink
Adding an ingress service (pulumi#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidobrien1985 authored and lblackstone committed Apr 29, 2019
1 parent dbf38b6 commit 8a1717f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions gcp-py-gke/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ After cloning this repo, `cd` into it and run these commands. A GKE Kubernetes c
+ ├─ gcp:container:Cluster gke-cluster create
+ ├─ pulumi:providers:kubernetes gkeK8s create
+ └─ kubernetes:apps:Deployment canary create
+ └─ kubernetes:core:Service ingress create
---outputs:---
kubeConfig: "apiVersion: v1\n..."
info: 4 changes updated:
+ 4 resources created
info: 5 changes updated:
+ 5 resources created
Update duration: 2m07.424737735s
```
Expand Down
11 changes: 11 additions & 0 deletions gcp-py-gke/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pulumi_gcp.container import Cluster
from pulumi_kubernetes import Provider
from pulumi_kubernetes.apps.v1 import Deployment
from pulumi_kubernetes.core.v1 import Service

# Read in some configurable settings for our cluster:
config = Config(None)
Expand Down Expand Up @@ -80,5 +81,15 @@
}, __opts__=ResourceOptions(provider=k8s_provider)
)

ingress = Service('ingress',
spec={
'type': 'LoadBalancer',
'selector': labels,
'ports': [{'port': 80}],
}, __opts__=ResourceOptions(provider=k8s_provider)
)

# Finally, export the kubeconfig so that the client can easily access the cluster.
export('kubeconfig', k8s_config)
# Export the k8s ingress IP to access the canary deployment
export('ingress_ip', Output.all(ingress.status['load_balancer']['ingress'][0]['ip']))

0 comments on commit 8a1717f

Please sign in to comment.