Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.
Open

argo #76

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions todo-app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:20.2.0-alpine3.18 as BUILD

RUN mkdir /opt/todo
WORKDIR /opt/todo

COPY . .

RUN npm install
RUN npm run build

FROM nginx:alpine3.17-slim

COPY --from=BUILD /opt/todo/dist/ /usr/share/nginx/html/
COPY default.conf.template /etc/nginx/templates/default.conf.template

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
5 changes: 5 additions & 0 deletions todo-app/charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2 # Helm chart API version
name: todo # Name of the Helm chart
description: A Helm chart for a todo app # Description of the chart
version: 0.1.0 # Version of the chart
appVersion: 0.1 # Version of the app that this chart deploys
55 changes: 55 additions & 0 deletions todo-app/charts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Helm Chart for Todo App

This Helm chart is designed to deploy a Web5 Todo application on a Kubernetes cluster. The chart uses Argo for GitOps deployment, allowing for version-controlled and automated deployments. The todo app is a simple react project that is built with a docker command beforehand.

```bash
docker buildx build -f Dockerfile --platform linux/amd64 -t todo:0.1 .
```

## Overview

Here's a quick overview of the files and what they do:

1. **Chart.yaml**: This is the metadata about the Helm chart itself like the name of the chart, its version, and the app version.

2. **values.yaml**: This file defines the default values for the chart's configurable parameters. Parameters include the image repository and tag, the type of service, and the port number.

3. **templates/deployment.yaml**: This file defines the Kubernetes Deployment for the Todo app. It specifies that one replica of the app should be running, and it uses the image specified in `values.yaml`.

4. **templates/service.yaml**: This file defines the Kubernetes Service for the Todo app, which provides network access to the deployment. The type and port of the service are specified in `values.yaml`.

5. **templates/ingress.yaml**: This file defines the Istio VirtualService, which controls how traffic is routed to the app. The host and gateway for the VirtualService are specified in `values.yaml`.

6. **templates/networkpolicy.yaml**: This file defines an Istio AuthorizationPolicy, which controls access to the app. It allows traffic from the `istio-system` namespace to the `todo.tbddev.org` host.

## Usage

To install this chart on your Kubernetes cluster, first make sure you have Helm and Argo installed and correctly configured.

Then, clone this repository and install the chart with a release name of your choice. For example, to install with the release name `todo`:

```bash
helm install --create-namespace --namespace todo todo .
```

The app's image, service, Istio host, and Istio gateway are all configurable via values.yaml. You can override these values by creating your own values file and passing it during installation with -f myvalues.yaml.

For example, to use a different image and host:

```yaml
# myvalues.yaml
image:
repository: myrepo/todo
tag: 1.0.0
istio:
host: myhost.example.com
```

```bash
helm install --create-namespace --namespace todo todo -f myvalues.yaml .
```

This makes the chart flexible and reusable for different environments or configurations.

## Conclusion
This Helm chart provides a convenient way to deploy the Todo app on any Kubernetes cluster. The chart also allows for version-controlled, automated deployments. Happy deploying!
22 changes: 22 additions & 0 deletions todo-app/charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: apps/v1 # API version for Deployment
kind: Deployment # Kind of Kubernetes object
metadata: # Metadata about the Deployment
name: todo-deployment # Name of the Deployment
labels: # Labels to attach to the Deployment
app: todo
spec: # Specification for the Deployment
replicas: 1 # Number of replicas to maintain
selector: # Label selector to identify the pods for this Deployment
matchLabels: # Match pods with these labels
app: todo
template: # Template for the pods in this Deployment
metadata: # Metadata about the pod
labels: # Labels to attach to the pod
app: todo
spec: # Specification for the pod
containers: # List of containers in the pod
- name: todo # Name of the container
image: {{ .Values.image.repository }}:{{ .Values.image.tag }} # Image for the container
ports: # List of ports to open in the container
- containerPort: 80 # Port to open
imagePullPolicy: IfNotPresent # Kubernetes image pull policy
15 changes: 15 additions & 0 deletions todo-app/charts/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: networking.istio.io/v1alpha3 # API version for Istio VirtualService
kind: VirtualService # Kind of Istio object
metadata: # Metadata about the VirtualService
name: todo-vservice # Name of the VirtualService
spec: # Specification for the VirtualService
hosts: # List of hosts that this VirtualService applies to
- {{ .Values.istio.host }}
gateways: # List of Gateways that this VirtualService is associated with
- {{ .Values.istio.gateway }}
http: # List of HTTP routes for this VirtualService
- route: # Details about the route
- destination: # Details about the destination of the route
port: # Port on the destination
number: {{ .Values.service.port }}
host: todo-service # Hostname of the destination
14 changes: 14 additions & 0 deletions todo-app/charts/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: security.istio.io/v1beta1 # API version for Istio AuthorizationPolicy
kind: AuthorizationPolicy # Kind of Istio object
metadata: # Metadata about the AuthorizationPolicy
name: todo-host # Name of the AuthorizationPolicy
spec: # Specification for the AuthorizationPolicy
action: ALLOW # Default action for requests
rules: # List of rules for this policy
- to: # List of destinations for this rule
- operation: # Details about the operation for this rule
hosts: # Hosts that this rule applies to
- "todo.tbddev.org"
- from: # List of sources for this rule
- source: # Details about the source for this rule
namespaces: ["istio-system"] # Namespaces that this rule applies to
11 changes: 11 additions & 0 deletions todo-app/charts/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1 # API version for Service
kind: Service # Kind of Kubernetes object
metadata: # Metadata about the Service
name: todo-service # Name of the Service
spec: # Specification for the Service
type: {{ .Values.service.type }} # Type of Service
ports: # List of ports for the Service
- port: {{ .Values.service.port }} # Port for the Service to listen on
targetPort: {{ .Values.service.targetPort }} # Port on the app's containers to direct traffic to
selector: # Label selector to identify the pods for this Service
app: todo
17 changes: 17 additions & 0 deletions todo-app/charts/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
replicaCount: 1 # Number of instances of the app to run

image: # Details about the Docker image for the app
repository: "844731274526.dkr.ecr.us-west-2.amazonaws.com/todo" # Docker image repository, this has been deployed with to AWS beforehand
tag: "0.0.3" # Docker image tag
pullPolicy: IfNotPresent # Kubernetes image pull policy

service: # Details about the Kubernetes Service for the app
type: ClusterIP # Type of Service
port: 80 # Port for the Service to listen on
targetPort: 80 # Port on the app's container to direct traffic to

istio: # Details about the Istio VirtualService for the app
host: "todo.tbddev.org" # Hostname that the VirtualService will handle
gateway: "istio-system/primary-gateway" # Istio Gateway that the VirtualService will be associated with

resources: {} # Resource requests and limits for the app's pod
10 changes: 10 additions & 0 deletions todo-app/default.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
server {
listen 80;
charset utf-8;
root /usr/share/nginx/html;
index index.html index.htm;
location / {
root /usr/share/nginx/html;
try_files $uri /index.html;
}
}