Skip to content

Commit 22446ae

Browse files
committed
k8s object + bucket tf
1 parent 6b8a6b8 commit 22446ae

File tree

11 files changed

+159
-0
lines changed

11 files changed

+159
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
gcpServiceAccount/credentials.json
2+
storage/.terraform/plugins

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
# velero
22
Backing-up, restoring and migrating kubernetes cluster with velero📦
3+
4+
## starting a docker conatiner with terraform installed
5+
```bash
6+
docker run -it --rm -v ${PWD}/storage:/storage -w /storage akshit8/terraform
7+
8+
chmod +x .terraform/providers/registry.terraform.io/hashicorp/google/3.54.0/linux_amd64/terraform-provider-google_v3.54.0_x5
9+
```

gcpServiceAccount/README.md

Whitespace-only changes.

k8s-objects/config.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: sample-config
5+
data:
6+
config.json: |
7+
{
8+
"environment" : "dev"
9+
}

k8s-objects/deployment.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: sample-app
5+
labels:
6+
app: sample-app
7+
annotations:
8+
spec:
9+
selector:
10+
matchLabels:
11+
app: sample-app
12+
replicas: 2
13+
strategy:
14+
type: RollingUpdate
15+
rollingUpdate:
16+
maxSurge: 1
17+
maxUnavailable: 0
18+
template:
19+
metadata:
20+
labels:
21+
app: sample-app
22+
spec:
23+
containers:
24+
- name: node-app
25+
image: akshit8/node-app
26+
imagePullPolicy: Always
27+
ports:
28+
- containerPort: 3000
29+
livenessProbe:
30+
httpGet:
31+
path: /started
32+
port: 3000
33+
initialDelaySeconds: 3
34+
periodSeconds: 3
35+
resources:
36+
requests:
37+
memory: "64Mi"
38+
cpu: "50m"
39+
limits:
40+
memory: "256Mi"
41+
cpu: "500m"
42+
#NOTE: comment out `volumeMounts` section for configmap and\or secret guide
43+
volumeMounts:
44+
- name: secret-volume
45+
mountPath: /secrets/
46+
- name: config-volume
47+
mountPath: /configs/
48+
#NOTE: comment out `volumes` section for configmap and\or secret guide
49+
volumes:
50+
- name: secret-volume
51+
secret:
52+
secretName: sample-secret
53+
- name: config-volume
54+
configMap:
55+
name: sample-config #name of our configmap object

k8s-objects/secret.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: sample-secret
5+
type: Opaque
6+
stringData:
7+
secret.json: |-
8+
{
9+
"api_key" : "somesecretgoeshere"
10+
}

k8s-objects/service.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: sample-service
5+
labels:
6+
app: sample-app
7+
spec:
8+
type: ClusterIP
9+
selector:
10+
app: sample-app
11+
ports:
12+
- protocol: TCP
13+
name: http
14+
port: 3000
15+
targetPort: 3000

storage/.terraform.lock.hcl

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

storage/main.tf

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
terraform {
2+
required_providers {
3+
google = {
4+
source = "hashicorp/google"
5+
version = "3.54.0"
6+
}
7+
}
8+
}
9+
10+
provider "google" {
11+
credentials = file(var.credentials_file)
12+
13+
project = var.project_id
14+
region = var.region
15+
}
16+
17+
resource "google_storage_bucket" "k8s-backup" {
18+
name = "velero-akshit"
19+
force_destroy = false
20+
location = "ASIA-EAST1"
21+
22+
storage_class = "STANDARD"
23+
24+
labels {
25+
usage = "storage bucket for k8s backup and restoration"
26+
}
27+
}

storage/variables.tf

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
variable "project_id" {
2+
default = "nodal-rex-284116"
3+
description = "project id"
4+
}
5+
6+
variable "region" {
7+
default = "asia-southeast1-c"
8+
description = "region"
9+
}
10+
11+
variable "credentials_file" {
12+
default = "gcpServiceAccount/credentials.json"
13+
description = "credential file name"
14+
}

0 commit comments

Comments
 (0)