Skip to content

Commit 3a6ffbb

Browse files
committed
Changed name to petshop
1 parent d06f0d3 commit 3a6ffbb

File tree

7 files changed

+72
-27
lines changed

7 files changed

+72
-27
lines changed

Makefile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# These can be overidden with env vars.
2-
REGISTRY ?= cluster-registry:32000
2+
REGISTRY ?= cluster-registry:5000
33
NAMESPACE ?= nyu-devops
4-
IMAGE_NAME ?= lab-flask-bdd
5-
IMAGE_TAG ?= 1.0
4+
IMAGE_NAME ?= petshop
5+
IMAGE_TAG ?= 1.0.0
66
IMAGE ?= $(REGISTRY)/$(NAMESPACE)/$(IMAGE_NAME):$(IMAGE_TAG)
77
PLATFORM ?= "linux/amd64,linux/arm64"
88
CLUSTER ?= nyu-devops
@@ -61,7 +61,7 @@ secret: ## Generate a secret hex key
6161
.PHONY: cluster
6262
cluster: ## Create a K3D Kubernetes cluster with load balancer and registry
6363
$(info Creating Kubernetes cluster with a registry and 1 node...)
64-
k3d cluster create nyu-devops --agents 1 --registry-create cluster-registry:0.0.0.0:32000 --port '8080:80@loadbalancer'
64+
k3d cluster create nyu-devops --agents 1 --registry-create cluster-registry:0.0.0.0:5000 --port '8080:80@loadbalancer'
6565

6666
.PHONY: cluster-rm
6767
cluster-rm: ## Remove a K3D Kubernetes cluster
@@ -71,7 +71,7 @@ cluster-rm: ## Remove a K3D Kubernetes cluster
7171
##@ Deploy
7272

7373
.PHONY: push
74-
image-push: ## Push to a Docker image registry
74+
push: ## Push to a Docker image registry
7575
$(info Logging into IBM Cloud cluster $(CLUSTER)...)
7676
docker push $(IMAGE)
7777

@@ -80,6 +80,11 @@ deploy: ## Deploy the service on local Kubernetes
8080
$(info Deploying service locally...)
8181
kubectl apply -f k8s/
8282

83+
.PHONY: undeploy
84+
undeploy: ## Delete the deployment on local Kubernetes
85+
$(info Removing service on Kubernetes...)
86+
kubectl delete -f k8s/
87+
8388
############################################################
8489
# COMMANDS FOR BUILDING THE IMAGE
8590
############################################################

README.md

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,64 @@ Pytest is configured to automatically include the flags `--pspec --cov=service -
7878

7979
These tests require the service to be running because unlike the the TDD unit tests that test the code locally, these BDD integration tests are using Selenium to manipulate a web page on a running server.
8080

81-
Run the tests using `behave`
81+
#### Run using two shells
8282

8383
Start the server in a separate bash shell:
8484

8585
```sh
8686
honcho start
8787
```
8888

89-
Then start behave in your original bash shell:
89+
Then start `behave` in your original bash shell:
9090

9191
```sh
9292
behave
9393
```
9494

9595
You will see the results of the tests scroll down yur screen using the familiar red/green/refactor colors.
9696

97+
#### Run using Kubernetes
98+
99+
You can also use Kubernetes to host your application and test against it with BDD. The commands to do this are:
100+
101+
```bash
102+
make cluster
103+
make build
104+
make push
105+
make deploy
106+
```
107+
108+
What did these commands do?
109+
110+
| Command | What does it do? |
111+
|---------|------------------|
112+
| make cluster | Creates a local Kubernetes cluster using `k3d` |
113+
| make build | Builds the Docker image |
114+
| make push | Pushes the image to the local Docker registry |
115+
| make deploy | Deploys the application using the image that was just built and pushed |
116+
117+
Now you can just run `behave` against the application running in the local Kubernetes cluster
118+
119+
```bash
120+
behave
121+
```
122+
123+
### See what images are in the local registry
124+
125+
You can use the `curl` command to query what images you have pushed to your local Docker registry. This will return `JSON` so you might want to use the silent flag `-s` and pipe it through `jq` like this:
126+
127+
```bash
128+
curl -XGET http://localhost:5000/v2/_catalog -s | jq
129+
```
130+
131+
That will return all of the image names without the tags.
132+
133+
To get the tags use:
134+
135+
```bash
136+
curl -XGET http://localhost:5000/v2/<image-name>/tags/list -s | jq
137+
```
138+
97139
## What's featured in the project?
98140

99141
```text
@@ -108,7 +150,7 @@ You will see the results of the tests scroll down yur screen using the familiar
108150

109151
## License
110152

111-
Copyright (c) 2016, 2023, John J. Rofrano. All rights reserved.
153+
Copyright (c) 2016, 2024, John J. Rofrano. All rights reserved.
112154

113155
Licensed under the Apache License. See [LICENSE](LICENSE)
114156

k3d-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: k3d.io/v1alpha3
22
kind: Simple
3-
name: devops
3+
name: nyu-devops
44
servers: 1
55
agents: 1
66
ports:
@@ -11,9 +11,9 @@ registries:
1111
create:
1212
name: cluster-registry
1313
host: "0.0.0.0"
14-
hostPort: "32000"
14+
hostPort: "5000"
1515
config: |
1616
mirrors:
17-
"cluster-registry:32000":
17+
"cluster-registry":
1818
endpoint:
19-
- http://cluster-registry:32000
19+
- http://cluster-registry:5000

k8s/deployment.yaml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
4-
name: lab-flask-bdd
4+
name: petshop
55
labels:
6-
app: lab-flask-bdd
6+
app: petshop
77
spec:
8-
replicas: 2
8+
replicas: 1
99
strategy:
1010
type: RollingUpdate
1111
rollingUpdate:
1212
maxSurge: 0%
1313
maxUnavailable: 50%
1414
selector:
1515
matchLabels:
16-
app: lab-flask-bdd
16+
app: petshop
1717
template:
1818
metadata:
1919
labels:
20-
app: lab-flask-bdd
20+
app: petshop
2121
spec:
22-
imagePullSecrets:
23-
- name: all-icr-io
2422
restartPolicy: Always
2523
containers:
26-
- name: lab-flask-bdd
27-
# image: cluster-registry:32000/lab-flask-bdd:1.0
28-
image: lab-flask-bdd
24+
- name: petshop
25+
image: cluster-registry:5000/nyu-devops/petshop:1.0.0
26+
# image: petshop
2927
imagePullPolicy: IfNotPresent
3028
ports:
3129
- containerPort: 8080

k8s/ingress.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: networking.k8s.io/v1
33
kind: Ingress
44
metadata:
5-
name: lab-flask-bdd
5+
name: petshop
66
annotations:
77
nginx.ingress.kubernetes.io/rewrite-target: /
88
spec:
@@ -13,6 +13,6 @@ spec:
1313
pathType: Prefix
1414
backend:
1515
service:
16-
name: lab-flask-bdd
16+
name: petshop
1717
port:
1818
number: 8080

k8s/postgresql.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ spec:
1818
spec:
1919
containers:
2020
- name: postgres
21-
image: postgres:alpine
21+
image: postgres:15-alpine
2222
ports:
2323
- containerPort: 5432
2424
protocol: TCP

k8s/service.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
apiVersion: v1
22
kind: Service
33
metadata:
4-
name: lab-flask-bdd
4+
name: petshop
55
spec:
66
selector:
7-
app: lab-flask-bdd
7+
app: petshop
88
type: ClusterIP
99
internalTrafficPolicy: Local
1010
ports:

0 commit comments

Comments
 (0)