Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,56 @@ minikube service text-compare-service
# 4. Web browser will be opened automatically to access the site.
```

# Use helm with k8s

Create helm chart with the following command.

```sh
helm create deployment
```

Then, edit the deployment file, service and config map file accordingly.

After editing all configuration files, install with helm.

```sh
helm install compare-helm deployment
```

Helm will create k8s components based on the configuration files. Use `kubectl get all | grep helm` to find them.

```sh
kubectl get all | grep helm
pod/compare-helm-76b67b5db6-r6jwq 1/1 Running 0 12m
service/compare-helm ClusterIP 10.97.189.245 <none> 80/TCP 12m
deployment.apps/compare-helm 1/1 1 1 12m
replicaset.apps/compare-helm-76b67b5db6 1 1 1 12m
```

If you make any change to the configuration files, use the following command to upgrade.

```sh
helm upgrade compare-helm deployment
```

List all deployed namespaces.

```sh
helm ls --all-namespaces
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
compare-helm default 2 2024-01-07 21:05:52.849445 -0800 PST deployed deployment-0.1.0 1.16.0
text-compare bit-developer 1 2024-01-07 20:50:29.372749 -0800 PST deployed deployment-0.1.0 1.16.0
text-compare default 1 2024-01-07 20:42:49.758154 -0800 PST failed deployment-0.1.0 1.16.0
```

Start the service to view the web app in brower.

```sh
minikube service compare-helm
```

- [How to Create Helm Charts - The Ultimate Guide](https://www.youtube.com/watch?v=jUYNS90nq8U&ab_channel=DevOpsJourney)

# Deployment
Read tutorial [Deploying Text Compare Angular App to Docker](https://jojozhuang.github.io/tutorial/deploying-text-compare-angular-app-to-docker) to learn how this angular app is deployed to Docker.

Expand Down
23 changes: 23 additions & 0 deletions deployment/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions deployment/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: deployment
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
7 changes: 7 additions & 0 deletions deployment/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: compare-configmap
#namespace: bit-developer
data:
ENV_NAME: 'DEV'
15 changes: 15 additions & 0 deletions deployment/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: compare-helm
#namespace: bit-developer
labels:
app: compare-helm
spec:
selector:
app: compare-helm
tier: frontend
ports:
- protocol: TCP
port: 80
type: NodePort
31 changes: 31 additions & 0 deletions deployment/templates/text-compare.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: compare-helm
#namespace: bit-developer
labels:
app: compare-helm
spec:
replicas: 1
selector:
matchLabels:
app: compare-helm
tier: frontend
template:
metadata:
labels:
app: compare-helm
tier: frontend
spec: # Pod spec
containers:
- name: compare-helm
image: jojozhuang/text-compare-angular
ports:
- containerPort: 80
resources:
requests:
memory: "16Mi"
cpu: "50m" # 500milliCPUs (1/2 CPU)
limits:
memory: "128Mi"
cpu: "100m"
Empty file added deployment/values.yaml
Empty file.