File size: 1,755 Bytes
9cb1789 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# Kubernetes Job Deployment Guide
This guide provides step-by-step instructions to deploy a Kubernetes Job using environment variables stored in a `.env` file.
## Step 1: Create a `.env` File
Create a file named `.env` and add the following environment variables:
```sh
MODEL_NAME=meta-llama/Llama-3.1-70B
HUG_TOKEN=hf_SuperSecretSauce123
HUG_TOKEN_RT=hf_ThisIsNotTheTokenYouAreLookingFor
```
## Step 2: Build and Push Docker Image
Before running the Kubernetes Job, build and push the Docker image to a container registry (Docker Hub).
Build the Docker image:
```sh
docker build -t your-dockerhub-username/your-image-name:latest .
```
Push the image to Docker Hub:
```sh
docker push your-dockerhub-username/your-image-name:latest
```
Ensure that your Kubernetes Job YAML references this Docker image.
## Step 3: Create a Kubernetes Secret from the `.env` File
Run the following command to create a Kubernetes Secret from the `.env` file:
```sh
kubectl create secret generic subhasis-env --from-env-file=.env
```
## Step 4: Deploy the Kubernetes Job
Apply the Kubernetes Job YAML file to the cluster:
```sh
kubectl apply -f job.yaml
```
## Step 5: Check Job Status
Monitor the job status using:
```sh
kubectl get jobs
```
To check logs from the running pod:
```sh
kubectl logs -f <pod-name>
```
To get the pod name:
```sh
kubectl get pods
```
## Step 6: Clean Up Resources
To delete the job after completion:
```sh
kubectl delete job subhasis007
```
To remove the secret:
```sh
kubectl delete secret subhasis-env
```
---
This guide ensures that environment variables are securely managed and Kubernetes Jobs are efficiently deployed. 🚀
|