Skip to content
Open
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
50 changes: 50 additions & 0 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Infra CI

on:
push:
paths:
- 'terraform/**'
- 'kubernetes/**'
- '.github/workflows/pipeline.yaml'
pull_request:
paths:
- 'terraform/**'
- 'kubernetes/**'
- '.github/workflows/pipeline.yaml'

jobs:
terraform:
name: Terraform Checks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Terraform
uses: hashicorp/setup-terraform@v3

- name: Terraform Init
run: terraform -chdir=terraform init

- name: Terraform Format
run: terraform -chdir=terraform fmt -check

- name: Terraform Validate
run: terraform -chdir=terraform validate

kube-lint:
name: Kubernetes YAML Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install kubeval
run: |
curl -sLO https://github.com/instrumenta/kubeval/releases/latest/download/kubeval-linux-amd64.tar.gz
tar xf kubeval-linux-amd64.tar.gz
sudo mv kubeval /usr/local/bin/

- name: Lint Kubernetes YAML
run: |
find kubernetes -name '*.yaml' -print0 | xargs -0 -n1 kubeval
15 changes: 10 additions & 5 deletions kubernetes/cronjob-v2.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
apiVersion: batch/v1beta1
#apiVersion: batch/v1beta1
apiVersion: batch/v1
kind: CronJob
metadata:
name: "amazing-cron-job"
spec:
schedule: '*/15 9-19 * *'
#schedule: '*/15 9-19 * *'
schedule: '*/15 9-19 * * *'
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
spec:
restartPolicy: Never
concurrencyPolicy: Forbid
successfulJobHistoryLimit: 1
failedJobsHistoryLimit: 1
# concurrencyPolicy: Forbid
# successfulJobHistoryLimit: 1
# failedJobsHistoryLimit: 1
18 changes: 16 additions & 2 deletions kubernetes/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
apiVersion: batch/v1beta1
#apiVersion: batch/v1beta1
apiVersion: batch/v1
kind: CronJob
metadata:
name: amazing-cron-job
spec:
schedule: '*/1 * * * *'
startingDeadlineSeconds: 10
concurrencyPolicy: Allow
concurrencyPolicy: Allow
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox
args:
- /bin/sh
- -c
- echo Hello from the Kubernetes cluster!
restartPolicy: OnFailure

5 changes: 4 additions & 1 deletion kubernetes/frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ metadata:
spec:
containers:
- name: app
image: images.ta.example/app:v4
image: images.ta.example/app:v4
ports:
- containerPort: 80
restartPolicy: Always
23 changes: 15 additions & 8 deletions kubernetes/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
apiVersion: v1
#apiVersion: v1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-test
spec:
rules:
- host: *
http:
paths:
- path: /endpoint
backend:
serviceName: s1
servicePort: 80
# - host: *
- http:
paths:
- path: /endpoint
pathType: Prefix
# backend:
# serviceName: s1
# servicePort: 80
backend:
service:
name: s1
port:
number: 80
7 changes: 5 additions & 2 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ resource "aws_iam_instance_profile" "example_profile" {

resource "aws_instance" "web" {
ami = data.aws_ami.ubuntu.id
instance_type = "t2.macro"
#instance_type = "t2.macro"
instance_type = "t2.micro"
# Added below line
iam_instance_profile = aws_iam_instance_profile.example_profile.name


root_block_device {
volume_type = "gp3"
Expand All @@ -84,5 +88,4 @@ resource "aws_instance" "web" {
tags = {
Name = "${local.project}"
}

}