Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kubernetes instructions and deployment config #16

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
55 changes: 54 additions & 1 deletion Usecases/Kubernetes Cluster/Readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
# Use-Case - Build a Kubernetes Cluster

## Step-by-Step Instructions
## Step-by-Step Instructions

### Step-1 - Create a cluster in GKE Autopilot mode

- In the Google Cloud Console, create a cluster on the **Kubernetes clusters** page
- Cluster basics: specify a name and region for the cluster, and use default values for other fields:

```
name: ncar-autopilot-cluster-1
region: us-central1
```
- Networking: use default values and continue
- Advanced settings: use default values and continue

### Step-1 (alternative) - Create a cluster from the command line
- Open a Google Cloud Shell terminal and run the following command

```
gcloud container clusters create-auto "ncar-autopilot-cluster-1" \
--project "i2class-fall2023-dmdevrie" \
--region "us-central1" \
--release-channel "regular" \
--network "projects/i2class-fall2023-dmdevrie/global/networks/default" \
--subnetwork "projects/i2class-fall2023-dmdevrie/regions/us-central1/subnetworks/default" \
--cluster-ipv4-cidr "/17"
```

### Step-2 - Add a deployment

- From the **Kubernetes clusters** page, select `+DEPLOY`
- In addition to the nginx container, add the NCAR subsetting container. Select 'Add a container'.
- Choose `Existing container` and select the container `us-central1-docker.pkg.dev/i2class-fall2023-dmdevrie/ncar-transform/ncar-subset` from the Artifact Registry.
- Set the deployment name and app label (these should be the same):

```
Deployment name: ncar-subset
Labels: {
app: ncar-subset
}
```

### Updating the deployment
- Subsequent changes to the deployment can be made by modifying `deployment.yaml`. Open a Google Cloud Shell terminal and run the following command to apply the changes:

First retrieve auth credentials for the cluster and verify
```
gcloud container clusters get-credentials ncar-autopilot-cluster-1 --zone=us-central1
kubectl cluster-info
```

Then apply the changes
```
kubectl apply -f deployment.yaml
```
50 changes: 50 additions & 0 deletions Usecases/Kubernetes Cluster/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
apiVersion: "apps/v1"
kind: "Deployment"
metadata:
name: "ncar-subset-1"
namespace: "default"
labels:
app: "ncar-subset-1"
spec:
replicas: 3
selector:
matchLabels:
app: "ncar-subset-1"
template:
metadata:
labels:
app: "ncar-subset-1"
spec:
containers:
- name: "nginx-1"
image: "nginx:latest"
- name: "docker-2"
image: "docker:latest"
- name: "ncar-subset-sha256-3"
image: "us-central1-docker.pkg.dev/i2class-fall2023-dmdevrie/ncar-transform/ncar-subset@sha256:7fcaf853a4262dc1f548d55a74753ac15a12a7a2490b1cd58cd24afb2bb4a0a2"
command:
- "docker run -t test-ncar-subset https://stratus.rda.ucar.edu/ds633.0/e5.oper.an.sfc/198010/e5.oper.an.sfc.128_167_2t.ll025sc.1980100100_1980103123.nc\
\ 85 75 70 40 gs://ncar-subset-target/test-user-target/"
---
apiVersion: "autoscaling/v2"
kind: "HorizontalPodAutoscaler"
metadata:
name: "ncar-subset-1-hpa-dtvf"
namespace: "default"
labels:
app: "ncar-subset-1"
spec:
scaleTargetRef:
kind: "Deployment"
name: "ncar-subset-1"
apiVersion: "apps/v1"
minReplicas: 1
maxReplicas: 5
metrics:
- type: "Resource"
resource:
name: "cpu"
target:
type: "Utilization"
averageUtilization: 80