Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
Fixes for contacts app (#11)
Browse files Browse the repository at this point in the history
* Makefile fixes

* Regenerate pb.gorm.go

* Remove redundant deploy yaml

* Fix deployment file

* Nginx

* Readme updates and namespace

* Empty line at the end of file
  • Loading branch information
Evgeniy-L authored May 2, 2018
1 parent 0d54df0 commit 7003bfb
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 114 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bin
.vscode
debug
vendor
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ PROJECT_ROOT := github.com/infobloxopen/atlas-contacts-app
BUILD_PATH := bin
DOCKERFILE_PATH := $(CURDIR)/docker

USERNAME := $(USER)
GIT_COMMIT := $(shell git describe --dirty=-unsupported --always || echo pre-commit)
IMAGE_VERSION ?= v1.0
IMAGE_VERSION ?= latest

SERVER_BINARY := $(BUILD_PATH)/server
SERVER_PATH := $(PROJECT_ROOT)/cmd/server
Expand Down Expand Up @@ -92,13 +90,11 @@ vendor-update:
$(BUILDER) dep ensure

.PHONY: image
image:
docker build -f docker/Dockerfile.contacts-server -t infoblox/contacts-server:v1.0 .
docker build -f docker/Dockerfile.contacts-gateway -t infoblox/contacts-gateway:v1.0 .
image: server gateway

.PHONY: image-clean
image-clean:
docker rmi -f infoblox/contacts-server:v1.0 infoblox/contacts-gateway:v1.0
docker rmi -f $(SERVER_IMAGE) $(GATEWAY_IMAGE)

.PHONY: up
up:
Expand All @@ -107,3 +103,11 @@ up:
.PHONY: down
down:
kubectl delete -f kube/kube.yaml

.PHONY: nginx-up
nginx-up:
kubectl apply -f kube/nginx.yaml

.PHONY: nginx-down
nginx-down:
kubectl delete -f kube/nginx.yaml
48 changes: 37 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,38 +61,64 @@ curl http://localhost:8080/atlas-contacts-app/v1/contacts -d '{"first_name": "Bo

``` sh
curl http://localhost:8080/atlas-contacts-app/v1/contacts?_filter='first_name=="Mike"'
```

#### Local Kubernetes setup

Open a seperate terminal session where execute `eval $(minikube docker-env)`. This is needed to make these images available for local kubernetes without pushing them to global repo.
##### Prerequisites

Make sure nginx is deployed in you K8s. Otherwise you can deploy it using

``` sh
make nginx-up
```

or by running

Then:
``` sh
kubectl apply -f kube/nginx.yaml
```

If you launching atlas-contacts-app for the first time you need to create `contacts` namespace for it in Kubernetes. This can be done by running

``` sh
kubectl apply -f kube/ns.yaml
```

or

``` sh
kubectl create ns contacts
```

##### Deployment

To deploy atlas-contacts-app use

``` sh
make image
make up
```

To shutdown and cleanup:
or as alternative you can run

``` sh
make down
make image-clean
rm -rf bin
kubectl apply -f kube/kube.yaml
```

#### Try local Kubernetes atlas-contacts-app
##### Usage

Try it out by executing following curl commangs:

``` sh
curl http://$(minikube ip):31500/atlas-contacts-app/v1/contacts -d '{"first_name": "Mike", "email_address": "[email protected]"}'
curl https://minikube/atlas-contacts-app/v1/contacts -d '{"first_name": "Mike", "email_address": "[email protected]"}'
```

``` sh
curl http://$(minikube ip):31500/atlas-contacts-app/v1/contacts -d '{"first_name": "Bob", "email_address": "[email protected]"}'
curl https://minikube/atlas-contacts-app/v1/contacts -d '{"first_name": "Bob", "email_address": "[email protected]"}'
```

``` sh
curl http://$(minikube ip):31500/atlas-contacts-app/v1/contacts?_filter='first_name=="Mike"'
curl https://minikube/atlas-contacts-app/v1/contacts?_filter='first_name=="Mike"'
```

## Deployment
Expand Down
84 changes: 0 additions & 84 deletions deploy/contacts.yaml

This file was deleted.

6 changes: 3 additions & 3 deletions kube/kube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
rules:
- http:
paths:
- path: /contacts
- path: /atlas-contacts-app
backend:
serviceName: contacts-app
servicePort: 8080
Expand Down Expand Up @@ -53,7 +53,7 @@ spec:
- "0.0.0.0:8088"
- "-shealth"
- "0.0.0.0:8089"
image: infoblox/contacts-gateway:v1.0
image: infoblox/contacts-gateway:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
Expand Down Expand Up @@ -84,7 +84,7 @@ spec:
# note that authz also needs to be running in order to authorize
# requests to the contacts-app
# - "-authz=pdpserver.authz:5555"
image: infoblox/contacts-server:v1.0
image: infoblox/contacts-server:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9091
Expand Down
112 changes: 112 additions & 0 deletions kube/nginx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
kind: Service
apiVersion: v1
metadata:
name: nginx-default-backend
labels:
k8s-addon: ingress-nginx.addons.k8s.io
spec:
ports:
- port: 80
targetPort: http
selector:
app: nginx-default-backend
---
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: nginx-default-backend
labels:
k8s-addon: ingress-nginx.addons.k8s.io
spec:
replicas: 1
template:
metadata:
labels:
k8s-addon: ingress-nginx.addons.k8s.io
app: nginx-default-backend
spec:
terminationGracePeriodSeconds: 60
containers:
- name: default-http-backend
image: gcr.io/google_containers/defaultbackend:1.0
livenessProbe:
httpGet:
path: /healthz
port: 8080
scheme: HTTP
initialDelaySeconds: 30
timeoutSeconds: 5
resources:
limits:
cpu: 10m
memory: 20Mi
requests:
cpu: 10m
memory: 20Mi
ports:
- name: http
containerPort: 8080
protocol: TCP
---
kind: ConfigMap
apiVersion: v1
metadata:
name: ingress-nginx
labels:
k8s-addon: ingress-nginx.addons.k8s.io
data:
use-proxy-protocol: "false"
---
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: ingress-nginx
labels:
k8s-addon: ingress-nginx.addons.k8s.io
spec:
replicas: 1
template:
metadata:
labels:
app: ingress-nginx
k8s-addon: ingress-nginx.addons.k8s.io
spec:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
terminationGracePeriodSeconds: 60
containers:
- image: gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.14
name: ingress-nginx
imagePullPolicy: Always
ports:
- name: http
containerPort: 80
protocol: TCP
- name: https
containerPort: 443
protocol: TCP
readinessProbe:
httpGet:
path: /healthz
port: 10254
scheme: HTTP
initialDelaySeconds: 10
livenessProbe:
httpGet:
path: /healthz
port: 10254
scheme: HTTP
initialDelaySeconds: 30
timeoutSeconds: 3
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
args:
- /nginx-ingress-controller
- --default-backend-service=$(POD_NAMESPACE)/nginx-default-backend
4 changes: 4 additions & 0 deletions kube/ns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: contacts
Loading

0 comments on commit 7003bfb

Please sign in to comment.