Skip to content

Commit 2f3fbc8

Browse files
authored
Merge pull request #18 from nyu-devops/update-fa23
More updates for Fall 2023 Semester
2 parents b669d7a + c9fbdbf commit 2f3fbc8

File tree

9 files changed

+37
-43
lines changed

9 files changed

+37
-43
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"hnw.vscode-auto-open-markdown-preview",
3737
"bierner.markdown-preview-github-styles",
3838
"davidanson.vscode-markdownlint",
39+
"tamasfe.even-better-toml",
3940
"donjayamanne.githistory",
4041
"GitHub.vscode-pull-request-github",
4142
"hbenl.vscode-test-explorer",

.devcontainer/scripts/install-tools.sh

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,8 @@ tar xvzf k9s.tar.gz
2929
sudo install -c -m 0755 k9s /usr/local/bin
3030
rm k9s.tar.gz
3131

32-
echo "**********************************************************************"
33-
echo "Install Kustomize CLI..."
34-
echo "**********************************************************************"
35-
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
36-
sudo mv kustomize /usr/local/bin/kustomize
37-
echo "Creating ku alias for kustomize..."
38-
echo "alias ku='/usr/local/bin/kustomize'" >> $HOME/.bash_aliases
39-
4032
echo "**********************************************************************"
4133
echo "Installing Skaffold..."
4234
echo "**********************************************************************"
4335
curl -Lo skaffold "https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-$ARCH"
4436
sudo install skaffold /usr/local/bin/
45-
46-
# echo "**********************************************************************"
47-
# echo "Installing Knative for $ARCH..."
48-
# echo "**********************************************************************"
49-
# curl -Lo kn "https://github.com/knative/client/releases/download/knative-v1.11.0/kn-linux-$ARCH"
50-
# sudo install kn /usr/local/bin/
51-
52-
echo "**********************************************************************"
53-
echo "Installing YQ..."
54-
echo "**********************************************************************"
55-
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_$ARCH
56-
sudo chmod a+x /usr/local/bin/yq

.devcontainer/scripts/setup-lab.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ echo "Setting up Docker lab environment..."
33
docker pull python:3.11-slim
44
docker run -d --name redis -p 6379:6379 -v redis:/data redis:6-alpine
55
echo Setting up registry.local...
6-
sudo bash -c "echo '127.0.0.1 k3d-registry.local' >> /etc/hosts"
6+
sudo bash -c "echo '127.0.0.1 cluster-registry' >> /etc/hosts"
77
echo "Setup complete"

Makefile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# These can be overidden with env vars.
2-
REGISTRY ?= rofrano
2+
REGISTRY ?= cluster-registry:32000
33
IMAGE_NAME ?= hitcounter
44
IMAGE_TAG ?= 1.0
55
IMAGE ?= $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)
66
PLATFORM ?= "linux/amd64,linux/arm64"
77
CLUSTER ?= nyu-devops
88

9+
.SILENT:
10+
911
.PHONY: help
1012
help: ## Display this help.
1113
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
@@ -50,19 +52,22 @@ run: ## Run the service
5052
$(info Starting service...)
5153
honcho start
5254

55+
.PHONY: secret
56+
secret: ## Generate a secret hex key
57+
$(info Generating a new secret key...)
58+
python3 -c 'import secrets; print(secrets.token_hex())'
59+
5360
##@ Kubernetes
5461

5562
.PHONY: cluster
5663
cluster: ## Create a K3D Kubernetes cluster with load balancer and registry
5764
$(info Creating Kubernetes cluster with a registry and 1 worker node...)
58-
k3d registry create registry.local --port 5000
59-
k3d cluster create devops --agents 1 --registry-use k3d-registry.local:5000 --port '8080:80@loadbalancer'
65+
k3d cluster create nyu-devops --agents 1 --registry-create cluster-registry:0.0.0.0:32000 --port '8080:80@loadbalancer'
6066

6167
.PHONY: cluster-rm
6268
cluster-rm: ## Remove a K3D Kubernetes cluster
6369
$(info Removing Kubernetes cluster...)
64-
k3d cluster delete devops
65-
k3d registry delete registry.local
70+
k3d cluster delete nyu-devops
6671

6772
.PHONY: tekton
6873
tekton: ## Install Tekton
@@ -89,7 +94,7 @@ knative: ## Install Knative
8994
.PHONY: deploy
9095
depoy: ## Deploy the service on local Kubernetes
9196
$(info Deploying service locally...)
92-
kubectl apply -k kustomize/overlay/local
97+
kubectl apply -f k8s/
9398

9499
############################################################
95100
# COMMANDS FOR BUILDING THE IMAGE
@@ -112,7 +117,7 @@ build: ## Build all of the project Docker images
112117
.PHONY: buildx
113118
buildx: ## Build multi-platform image with buildx
114119
$(info Building multi-platform image $(IMAGE) for $(PLATFORM)...)
115-
docker buildx build --file Dockerfile --pull --platform=$(PLATFORM) --tag $(IMAGE) --load .
120+
docker buildx build --file Dockerfile --pull --platform=$(PLATFORM) --tag $(IMAGE) --push .
116121

117122
.PHONY: remove
118123
remove: ## Stop and remove the buildx builder

k3d-config.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
apiVersion: k3d.io/v1alpha5
1+
apiVersion: k3d.io/v1alpha3
22
kind: Simple
3+
name: devops
34
servers: 1
45
agents: 1
56
ports:
67
- port: 8080:80
78
nodeFilters:
89
- loadbalancer
910
registries:
11+
create:
12+
name: cluster-registry
13+
host: "0.0.0.0"
14+
hostPort: "32000"
1015
config: |
1116
mirrors:
12-
"k3d-registry.local:5000":
17+
"cluster-registry:32000":
1318
endpoint:
14-
- http://k3d-registry.local:5000
19+
- http://cluster-registry:32000

k8s/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ spec:
2222
restartPolicy: Always
2323
containers:
2424
- name: hitcounter
25-
# image: k3d-registry.local:5000/hitcounter:1.0
26-
image: hitcounter
25+
image: cluster-registry:32000/hitcounter:1.0
26+
# image: hitcounter
2727
imagePullPolicy: IfNotPresent
2828
ports:
2929
- containerPort: 8080

requirements.txt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
# Pinned dependencies that cause breakage
2-
Werkzeug==2.3.3
2+
Werkzeug==2.3.7
33

44
# Runtime dependencies
5-
Flask==2.3.2
5+
Flask==2.3.3
66
redis==4.5.4
77
retry2==0.9.5
8-
python-dotenv==0.21.1
8+
python-dotenv==1.0.0
99

1010
# Runtime dependencies
11-
gunicorn==20.1.0
11+
gunicorn==21.2.0
1212
honcho==1.1.0
1313

1414
# Code quality
15-
pylint==2.16.2
16-
flake8==6.0.0
17-
black==23.1.0
15+
pylint==2.17.5
16+
flake8==6.1.0
17+
black==23.7.0
1818

1919
# Testing dependencies
20+
pytest==7.4.0
21+
pytest-pspec==0.0.4
22+
pytest-cov==4.1.0
23+
coverage==7.3.0
2024
green==3.4.3
21-
coverage==7.1.0
2225

2326
# Utilities
2427
httpie==3.2.2

skaffold.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
SKAFFOLD_DEFAULT_REPO=k3d-registry.local:5000
1+
SKAFFOLD_DEFAULT_REPO=cluster-registry:32000

skaffold.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ test:
1414
- context: .
1515
image: hitcounter
1616
custom:
17-
- command: export DATABASE_URI=redis://localhost:6379/0 green
17+
- command: export RETRY_COUNT=1; DATABASE_URI=redis://localhost:6379/0 green
1818
manifests:
1919
rawYaml:
2020
- k8s/deployment.yaml

0 commit comments

Comments
 (0)