https://github.com/mathieu-benoit/nginx-score-demo
https://github.com/mathieu-benoit/nginx-score-demo
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/mathieu-benoit/nginx-score-demo
- Owner: mathieu-benoit
- Created: 2025-01-13T18:18:51.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-10T11:18:37.000Z (about 1 year ago)
- Last Synced: 2025-05-10T12:25:22.965Z (about 1 year ago)
- Language: Shell
- Size: 26.4 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nginx-score-demo
[](https://codespaces.new/mathieu-benoit/nginx-score-demo)
A Developer authors and maintains their files in the [`website`](./website/) folder, their [`Dockerfile`](Dockerfile) and the [`score.yaml`](score.yaml) file.
Then, they can deploy their `score.yaml` file with three options:
- [Deploy with `score-compose`](#deploy-with-score-compose)
- [Deploy with `score-k8s`](#deploy-with-score-k8s)
- [Deploy with `humctl`](#deploy-with-humctl)
## Deploy with `score-compose`
Initialize the local `score-compose` workspace:
```bash
score-compose init \
--no-sample \
--provisioners https://raw.githubusercontent.com/score-spec/community-provisioners/refs/heads/main/horizontal-pod-autoscaler/score-compose/10-hpa.provisioners.yaml \
--patch-templates https://raw.githubusercontent.com/score-spec/community-patchers/refs/heads/main/score-compose/unprivileged.tpl
```
Generate the Docker Compose files:
```bash
score-compose generate score.yaml \
--build 'webapp={"context":"."}'
```
Deploy the Docker Compose files:
```bash
docker compose up --build -d --remove-orphans
```
Test the deployed Workload:
```bash
curl $(score-compose resources get-outputs dns.default#nginx.dns --format '{{ .host }}:8080')
```
## Deploy with `score-k8s`
Prepare the cluster:
```bash
./scripts/setup-kind-cluster.sh
CONTAINER_IMAGE=nginx-score-demo-nginx-webapp:latest
kind load docker-image ${CONTAINER_IMAGE}
NAMESPACE=default
kubectl create ns $NAMESPACE
kubectl label ns $NAMESPACE pod-security.kubernetes.io/enforce=restricted
```
Initialize the local `score-k8s` workspace:
```bash
score-k8s init \
--no-sample \
--provisioners https://raw.githubusercontent.com/score-spec/community-provisioners/refs/heads/main/horizontal-pod-autoscaler/score-k8s/10-hpa.provisioners.yaml \
--patch-templates https://raw.githubusercontent.com/score-spec/community-patchers/refs/heads/main/score-k8s/service-account.tpl \
--patch-templates https://raw.githubusercontent.com/score-spec/community-patchers/refs/heads/main/score-k8s/unprivileged.tpl
```
Generate the Kubernetes manifests:
```bash
score-k8s generate score.yaml \
--image ${CONTAINER_IMAGE}
```
Deploy the Kubernetes manifests:
```bash
kubectl apply -n $NAMESPACE -f manifests.yaml
```
Test the deployed Workload:
```bash
curl $(score-k8s resources get-outputs dns.default#nginx.dns --format '{{ .host }}')
```
## Deploy with `humctl`
Deploy the Score file in Humanitec:
```bash
CONTAINER_IMAGE_IN_REGISTRY=FIXME
humctl score deploy -f score.yaml \
--app ${APP} \
--env ${ENV} \
--image ${CONTAINER_IMAGE_IN_REGISTRY}
```
_Note: this is assuming that Platform Engineers have registered the following [`volume`](https://developer.humanitec.com/examples/resource-definitions?capability=volumes), [`horizontal-pod-autoscaler`](https://developer.humanitec.com/examples/resource-definitions?capability=horizontal-pod-autoscaler) and [`workload` with `securityContext`](https://developer.humanitec.com/examples/resource-definitions/template-driver/security-context/) in Humanitec._
Test the deployed Workload:
```bash
humctl get active-resources \
--app ${APP} \
--env ${ENV} \
-o json \
| jq -r '. | map(. | select(.metadata.type == "dns")) | map((.metadata.res_id | split(".") | .[1]) + ": [" + .status.resource.host + "](https://" + .status.resource.host + ")") | join("\n")'
```