Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kubenews #11

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
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
76 changes: 76 additions & 0 deletions Deployment/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgre
spec:
selector:
matchLabels:
app: postgre
template:
metadata:
labels:
app: postgre
spec:
containers:
- name: postgre
image: postgres:14.3
ports:
- containerPort: 5432
env:
- name: DB_PASSWORD
value: "PASS"
- name: DB_USERNAME
value: "TESTUSER"
- name: DB_DATABASE
value: "KUBE-NEWS"
---
apiVersion: v1
kind: Service
metadata:
name: postgre
spec:
selector:
app: postgre
ports:
- port: 5432
nodePort: 5432
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: testedp
spec:
replicas: 3
selector:
matchLabels:
app: testedp
template:
metadata:
labels:
app: testedp
spec:
containers:
- name: kubenews
image: IMAGE #fabricioveronez/kube-news:v2
env:
- name: DB_DATABASE
value: "KUBE-NEWS"
- name: DB_USERNAME
value: "TESTUSER"
- name: DB_PASSWORD
value: "PASS"
- name: DB_HOST
value: "postgre"
---
apiVersion: v1
kind: Service
metadata:
name: kube-news
spec:
selector:
app: kubenews
ports:
- port: 80
targetPort: 8080
nodePort: 30000
type: LoadBalancer
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node
WORKDIR /app
COPY ./package*.json ./
RUN npm install
COPY . .
EXPOSE 8080
CMD ["node", "server.js"]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# kube-news
# kube-news

### Repositório base para o cumprimento dos desafios do Iniciativa DevOps✅
43 changes: 43 additions & 0 deletions Terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions Terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.0"
}
}
}

provider "digitalocean" {
token = "https://youtu.be/K7wDMwJrv-k"
}

resource "digitalocean_kubernetes_cluster" "k8s_iniciativa" {
name = var.k8s_name
region = var.region
# Grab the latest version slug from `doctl kubernetes options versions`
version = "1.23.9-do.0"

node_pool {
name = "default"
size = "s-2vcpu-2gb"
node_count = 2
}
}

resource "digitalocean_kubernetes_node_pool" "node_premium" {
cluster_id = digitalocean_kubernetes_cluster.k8s_iniciativa.id

name = "premium"
size = "s-4vcpu-8gb"
node_count = 1

}

variable "https://youtu.be/K7wDMwJrv-k" {}
variable "k8s_name" {}
variable "region" {}

output "kube_endpoint" {
value = digitalocean_kubernetes_cluster.k8s_iniciativa.endpoint
}

resource "local_file" "kube_config" {
content = digitalocean_kubernetes_cluster.k8s_iniciativa.kube_config.0.raw_config
filename = "kube_config.yaml"
}
8 changes: 8 additions & 0 deletions Terraform/terraform.tfstate
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": 4,
"terraform_version": "1.0.0",
"serial": 21,
"lineage": "b99c2e81-b2e6-445b-badc-5da7f37e80cb",
"outputs": {},
"resources": []
}
172 changes: 172 additions & 0 deletions Terraform/terraform.tfstate.backup
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
{
"version": 4,
"terraform_version": "1.0.0",
"serial": 17,
"lineage": "b99c2e81-b2e6-445b-badc-5da7f37e80cb",
"outputs": {
"kube_endpoint": {
"value": "https://f8bd4479-ebb0-4af7-b45f-2e271fc41aad.k8s.ondigitalocean.com",
"type": "string"
}
},
"resources": [
{
"mode": "managed",
"type": "digitalocean_kubernetes_cluster",
"name": "k8s_iniciativa",
"provider": "provider[\"registry.terraform.io/digitalocean/digitalocean\"]",
"instances": [
{
"schema_version": 3,
"attributes": {
"auto_upgrade": false,
"cluster_subnet": "10.244.0.0/16",
"created_at": "2022-08-03 22:51:12 +0000 UTC",
"endpoint": "https://f8bd4479-ebb0-4af7-b45f-2e271fc41aad.k8s.ondigitalocean.com",
"ha": false,
"id": "f8bd4479-ebb0-4af7-b45f-2e271fc41aad",
"ipv4_address": "",
"kube_config": [
{
"client_certificate": "",
"client_key": "",
"cluster_ca_certificate": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURKekNDQWcrZ0F3SUJBZ0lDQm5Vd0RRWUpLb1pJaHZjTkFRRUxCUUF3TXpFVk1CTUdBMVVFQ2hNTVJHbG4KYVhSaGJFOWpaV0Z1TVJvd0dBWURWUVFERXhGck9ITmhZWE1nUTJ4MWMzUmxjaUJEUVRBZUZ3MHlNakE0TURNeQpNalV4TVRWYUZ3MDBNakE0TURNeU1qVXhNVFZhTURNeEZUQVRCZ05WQkFvVERFUnBaMmwwWVd4UFkyVmhiakVhCk1CZ0dBMVVFQXhNUmF6aHpZV0Z6SUVOc2RYTjBaWElnUTBFd2dnRWlNQTBHQ1NxR1NJYjNEUUVCQVFVQUE0SUIKRHdBd2dnRUtBb0lCQVFDMGhRZHVZVTlvOGxVNitJMHlvanhtK2h3a0JYa2F2c05UREw2aUlXTTZBdlpHZTZaZQp1OVRMdmdBS0ppUG5WTm9KaXV5UHBwVmpvRDMxSzVSOEwzTXNhNDZCd1NoWDl3V0JJdGRUN0N3V3p3OWtGcHFvCjVEYzloRG9EbVEwN1VWU09IL09jYVRoRDFqaWZnbnJxQ0JLTC9SWlF4UGFaSFFDVmcvK2dzNXBNUnB6dVg2VS8KUmduek12K0NXTUp6eDJQdlNhcFFEL0ZES1l6YS9LdHhpK0NTZ1ZqdlMwemJRQ3BhTXZ2V3dwQXlPU3gvMmIxawo5cGRlM2N0R1FYYmpDZE82VEF4L0lCY2JsQTFFZ0JrWDl2ZlNmQVBDMWhOLzUxOEdEZUZaTFA4Y3Y0OThQZVovCmIrMkhNblpkb2VQUWlIdDdMYi8ycTdMbHVhS09TR0lFeC91MUFnTUJBQUdqUlRCRE1BNEdBMVVkRHdFQi93UUUKQXdJQmhqQVNCZ05WSFJNQkFmOEVDREFHQVFIL0FnRUFNQjBHQTFVZERnUVdCQlQrK1M0TmZ5cmhKY0U2OHl1Nwo5S2VNekF0UitqQU5CZ2txaGtpRzl3MEJBUXNGQUFPQ0FRRUFCTXdnVTFRWXF3b2dnamkvRVpSaEFEYncxLzh6Ckw1ZWNXU3pkazc4RjFtKzhxaDFuMkNxbmlFQ0JiLzN1R3N1aENBTW1rU0FCbXNSTTJUSzBtYmlWOHBIdHptQXoKSnZibWlweUFlM21xYUM0NVo0T3dlUHh6VDc0QWRHWjVvbG8wSGtWenlTaVhrYkRFWEV5Tks2d0hvRUdNN1NwVQphVFZ5NTVid1poNTFZazc3cjBkbDJYTkFjS1lCTFJVdDJ0a2NwcDdPZWJLTDlwUisza2VpaENXVWlKUm1rNVVrCmg1UVJIOENiNmVMbU5rZUlFR1BRUXUvR0MwYzlnTEtzakFKY3N3L05ScDZORUZmMFI3bjM1K2hicUxLRmYrTEYKVTZFb0p4Q05vd05OemZ3WXZQYlRCTWlBUFF0Sk9QOHNIRUpSY2k3STNaZnZDbXQxZ2JVWkxST3V0dz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K",
"expires_at": "2022-08-10T22:56:42Z",
"host": "https://f8bd4479-ebb0-4af7-b45f-2e271fc41aad.k8s.ondigitalocean.com",
"raw_config": "apiVersion: v1\nkind: Config\nclusters:\n- cluster:\n certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURKekNDQWcrZ0F3SUJBZ0lDQm5Vd0RRWUpLb1pJaHZjTkFRRUxCUUF3TXpFVk1CTUdBMVVFQ2hNTVJHbG4KYVhSaGJFO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21xYUM0NVo0T3dlUHh6VDc0QWRHWjVvbG8wSGtWenlTaVhrYkRFWEV5Tks2d0hvRUdNN1NwVQphVFZ5NTVid1poNTFZazc3cjBkbDJYTkFjS1lCTFJVdDJ0a2NwcDdPZWJLTDlwUisza2VpaENXVWlKUm1rNVVrCmg1UVJIOENiNmVMbU5rZUlFR1BRUXUvR0MwYzlnTEtzakFKY3N3L05ScDZORUZmMFI3bjM1K2hicUxLRmYrTEYKVTZFb0p4Q05vd05OemZ3WXZQYlRCTWlBUFF0Sk9QOHNIRUpSY2k3STNaZnZDbXQxZ2JVWkxST3V0dz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K\n server: https://f8bd4479-ebb0-4af7-b45f-2e271fc41aad.k8s.ondigitalocean.com\n name: do-nyc1-k8s-iniciativa-danielrosas\ncontexts:\n- context:\n cluster: do-nyc1-k8s-iniciativa-danielrosas\n user: do-nyc1-k8s-iniciativa-danielrosas-admin\n name: do-nyc1-k8s-iniciativa-danielrosas\ncurrent-context: do-nyc1-k8s-iniciativa-danielrosas\nusers:\n- name: do-nyc1-k8s-iniciativa-danielrosas-admin\n user:\n token: dop_v1_3aa9be899775fc137b5103366190edfe4e9e4ea6d0bda687719348b65a0b0075\n",
"token": "dop_v1_3aa9be899775fc137b5103366190edfe4e9e4ea6d0bda687719348b65a0b0075"
}
],
"maintenance_policy": [
{
"day": "any",
"duration": "4h0m0s",
"start_time": "22:00"
}
],
"name": "k8s-iniciativa-danielrosas",
"node_pool": [
{
"actual_node_count": 2,
"auto_scale": false,
"id": "40d4d2cb-a173-4264-8975-d85d9cb0aa3a",
"labels": {},
"max_nodes": 0,
"min_nodes": 0,
"name": "default",
"node_count": 2,
"nodes": [
{
"created_at": "2022-08-03 22:51:12 +0000 UTC",
"droplet_id": "311118537",
"id": "a547e779-36aa-4f21-ae86-a00e6e96dddb",
"name": "default-7nqdk",
"status": "running",
"updated_at": "2022-08-03 22:53:16 +0000 UTC"
},
{
"created_at": "2022-08-03 23:29:16 +0000 UTC",
"droplet_id": "311121964",
"id": "d62338ef-ae14-4004-9b8f-9a992ca69263",
"name": "default-7nfxx",
"status": "running",
"updated_at": "2022-08-03 23:29:56 +0000 UTC"
}
],
"size": "s-2vcpu-2gb",
"tags": [],
"taint": []
}
],
"region": "nyc1",
"service_subnet": "10.245.0.0/16",
"status": "degraded",
"surge_upgrade": true,
"tags": [],
"timeouts": null,
"updated_at": "2022-08-03 23:31:54 +0000 UTC",
"urn": "do:kubernetes:f8bd4479-ebb0-4af7-b45f-2e271fc41aad",
"version": "1.23.9-do.0",
"vpc_uuid": "d0707df9-a29e-4301-9497-fe20fb9a6a28"
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxODAwMDAwMDAwMDAwfSwic2NoZW1hX3ZlcnNpb24iOiIzIn0="
}
]
},
{
"mode": "managed",
"type": "digitalocean_kubernetes_node_pool",
"name": "node_premium",
"provider": "provider[\"registry.terraform.io/digitalocean/digitalocean\"]",
"instances": [
{
"schema_version": 1,
"attributes": {
"actual_node_count": 1,
"auto_scale": false,
"cluster_id": "f8bd4479-ebb0-4af7-b45f-2e271fc41aad",
"id": "77821775-1e0d-4df6-b52f-6183ccee365e",
"labels": {},
"max_nodes": 0,
"min_nodes": 0,
"name": "premium",
"node_count": 1,
"nodes": [
{
"created_at": "2022-08-03 23:14:43 +0000 UTC",
"droplet_id": "311120601",
"id": "452b5498-2f88-42a0-818e-b0b78b40308c",
"name": "premium-7nfui",
"status": "running",
"updated_at": "2022-08-03 23:15:25 +0000 UTC"
}
],
"size": "s-4vcpu-8gb",
"tags": [],
"taint": [],
"timeouts": null
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxODAwMDAwMDAwMDAwLCJkZWxldGUiOjE4MDAwMDAwMDAwMDB9LCJzY2hlbWFfdmVyc2lvbiI6IjEifQ==",
"dependencies": [
"digitalocean_kubernetes_cluster.k8s_iniciativa"
]
}
]
},
{
"mode": "managed",
"type": "local_file",
"name": "kube_config",
"provider": "provider[\"registry.terraform.io/hashicorp/local\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"content": "apiVersion: v1\nkind: Config\nclusters:\n- cluster:\n certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURKekNDQWcrZ0F3SUJBZ0lDQm5Vd0RRWUpLb1pJaHZjTkFRRUxCUUF3TXpFVk1CTUdBMVVFQ2hNTVJHbG4KYVhSaGJFOWpaV0Z1TVJvd0dBWURWUVFERXhGck9ITmhZWE1nUTJ4MWMzUmxjaUJEUVRBZUZ3MHlNakE0TURNeQpNalV4TVRWYUZ3MDBNakE0TURNeU1qVXhNVFZhTURNeEZUQVRCZ05WQkFvVERFUnBaMmwwWVd4UFkyVmhiakVhCk1CZ0dBMVVFQXhNUmF6aHpZV0Z6SUVOc2RYTjBaWElnUTBFd2dnRWlNQTBHQ1NxR1NJYjNEUUVCQVFVQUE0SUIKRHdBd2dnRUtBb0lCQVFDMGhRZHVZVTlvOGxVNitJMHlvanhtK2h3a0JYa2F2c05UREw2aUlXTTZBdlpHZTZaZQp1OVRMdmdBS0ppUG5WTm9KaXV5UHBwVmpvRDMxSzVSOEwzTXNhNDZCd1NoWDl3V0JJdGRUN0N3V3p3OWtGcHFvCjVEYzloRG9EbVEwN1VWU09IL09jYVRoRDFqaWZnbnJxQ0JLTC9SWlF4UGFaSFFDVmcvK2dzNXBNUnB6dVg2VS8KUmduek12K0NXTUp6eDJQdlNhcFFEL0ZES1l6YS9LdHhpK0NTZ1ZqdlMwemJRQ3BhTXZ2V3dwQXlPU3gvMmIxawo5cGRlM2N0R1FYYmpDZE82VEF4L0lCY2JsQTFFZ0JrWDl2ZlNmQVBDMWhOLzUxOEdEZUZaTFA4Y3Y0OThQZVovCmIrMkhNblpkb2VQUWlIdDdMYi8ycTdMbHVhS09TR0lFeC91MUFnTUJBQUdqUlRCRE1BNEdBMVVkRHdFQi93UUUKQXdJQmhqQVNCZ05WSFJNQkFmOEVDREFHQVFIL0FnRUFNQjBHQTFVZERnUVdCQlQrK1M0TmZ5cmhKY0U2OHl1Nwo5S2VNekF0UitqQU5CZ2txaGtpRzl3MEJBUXNGQUFPQ0FRRUFCTXdnVTFRWXF3b2dnamkvRVpSaEFEYncxLzh6Ckw1ZWNXU3pkazc4RjFtKzhxaDFuMkNxbmlFQ0JiLzN1R3N1aENBTW1rU0FCbXNSTTJUSzBtYmlWOHBIdHptQXoKSnZibWlweUFlM21xYUM0NVo0T3dlUHh6VDc0QWRHWjVvbG8wSGtWenlTaVhrYkRFWEV5Tks2d0hvRUdNN1NwVQphVFZ5NTVid1poNTFZazc3cjBkbDJYTkFjS1lCTFJVdDJ0a2NwcDdPZWJLTDlwUisza2VpaENXVWlKUm1rNVVrCmg1UVJIOENiNmVMbU5rZUlFR1BRUXUvR0MwYzlnTEtzakFKY3N3L05ScDZORUZmMFI3bjM1K2hicUxLRmYrTEYKVTZFb0p4Q05vd05OemZ3WXZQYlRCTWlBUFF0Sk9QOHNIRUpSY2k3STNaZnZDbXQxZ2JVWkxST3V0dz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K\n server: https://f8bd4479-ebb0-4af7-b45f-2e271fc41aad.k8s.ondigitalocean.com\n name: do-nyc1-k8s-iniciativa-danielrosas\ncontexts:\n- context:\n cluster: do-nyc1-k8s-iniciativa-danielrosas\n user: do-nyc1-k8s-iniciativa-danielrosas-admin\n name: do-nyc1-k8s-iniciativa-danielrosas\ncurrent-context: do-nyc1-k8s-iniciativa-danielrosas\nusers:\n- name: do-nyc1-k8s-iniciativa-danielrosas-admin\n user:\n token: dop_v1_3aa9be899775fc137b5103366190edfe4e9e4ea6d0bda687719348b65a0b0075\n",
"content_base64": null,
"directory_permission": "0777",
"file_permission": "0777",
"filename": "kube_config.yaml",
"id": "d8fa0ef78902f6200ff0328835ec98e43fd62cf5",
"sensitive_content": null,
"source": null
},
"sensitive_attributes": [
[
{
"type": "get_attr",
"value": "content"
}
]
],
"private": "bnVsbA==",
"dependencies": [
"digitalocean_kubernetes_cluster.k8s_iniciativa"
]
}
]
}
]
}
25 changes: 25 additions & 0 deletions manifest-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v1
kind: pod
metadata:
name: testpodblue # no labels
spec:
containers:
name: appweb
image: fabricioveronez/web-page:blue
ports:
conteinerPort: 80

--- # --- permite declarar objetos num mesmo arquivo

apiVersion: v1
kind: pod
metadata:
name: testpodgreen
labels: # with labels
app: green
spec:
containers:
name: appweb
image: fabricioveronez/web-page:green
ports:
conteinerPort: 80
Loading