Skip to content
This repository has been archived by the owner on May 7, 2022. It is now read-only.

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
Felipe Coelho Nunziata Franco committed Nov 29, 2020
1 parent 7cfbbc3 commit fffca32
Show file tree
Hide file tree
Showing 41 changed files with 2,398 additions and 0 deletions.
45 changes: 45 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/sh

echo -e "Minikube Run ..."
echo -e "Might take a while to install everything and get the cluster ready."
minikube start --cpus=2 --vm-driver=docker --bootstrapper=kubeadm \
--extra-config=kubelet.authentication-token-webhook=true \
--extra-config=apiserver.service-node-port-range=3000-35000

# IF, you do not have Metallb addon in your minikube, you can download the manifest.
# and "comment" "enable metallb" line in Enabling Addons section.
# -------------------------------------
# echo -e "Setting Load balancer ..."
# kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.8.1/manifests/namespace.yaml
# kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.8.1/manifests/metallb.yaml
# echo -e "If already exists a member list, It will show an Error Message, but it is okay..."
# kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"

echo -e "Enabling Addons ..."
minikube addons enable metrics-server
minikube addons enable dashboard
minikube addons enable metallb

echo -e "Loading MetalLB ..."
kubectl apply -f ./srcs/metallb-config.yaml

echo -e "Launching Pods ..."
eval $(minikube docker-env)
docker build srcs/nginx -t nginx-img
docker build srcs/ftps -t ftps-img
docker build srcs/wordpress -t wordpress-img
docker build srcs/mysql -t mysql-img
docker build srcs/phpmyadmin -t phpmyadmin-img
docker build srcs/grafana -t grafana-img
docker build srcs/influxdb -t influxdb-img

echo -e "Configure Minikube ..."
kubectl apply -f ./srcs/nginx/nginx.yaml
kubectl apply -f ./srcs/ftps/ftps.yaml
kubectl apply -f ./srcs/mysql/mysql.yaml
kubectl apply -f ./srcs/wordpress/wordpress.yaml
kubectl apply -f ./srcs/phpmyadmin/phpmyadmin.yaml
kubectl apply -f ./srcs/influxdb/influxdb.yaml
kubectl apply -f ./srcs/grafana/grafana.yaml

echo -e "You can now proceed."
14 changes: 14 additions & 0 deletions srcs/ftps/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM alpine:3.12

LABEL maintainer="fcoelho <fcoelho@student.42sp.org.br>" \
version="1.0.0"

RUN apk upgrade && \
apk add openssl vsftpd

COPY setup.sh /tmp/
RUN chmod +x /tmp/setup.sh

EXPOSE 21 30000

ENTRYPOINT ["/tmp/setup.sh"]
92 changes: 92 additions & 0 deletions srcs/ftps/ftps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ftps
spec:
selector:
matchLabels:
app: ftps
strategy:
type: Recreate
template:
metadata:
name: ftps
labels:
app: ftps
spec:
containers:
- name: ftps
image: ftps-img
imagePullPolicy: Never
ports:
- name: ftps-connection
containerPort: 21
- name: passv-mode
containerPort: 30000
env:
- name: USERNAME
valueFrom:
secretKeyRef:
name: wordpress-secret
key: username
- name: PASSWORD
valueFrom:
secretKeyRef:
name: wordpress-secret
key: password
volumeMounts:
- name: ftps-config
mountPath: /etc/vsftpd
volumes:
- name: ftps-config
configMap:
name: ftps-config

---
apiVersion: v1
kind: Service
metadata:
annotations:
metallb.universe.tf/allow-shared-ip: shared
name: ftps
spec:
ports:
- name: ftps-connection
port: 21
- name: passv-mode
port: 30000
selector:
app: ftps
type: LoadBalancer
---
apiVersion: v1
kind: ConfigMap
metadata:
name: ftps-config
data:
vsftpd.conf: |
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
xferlog_std_format=YES
chroot_local_user=YES
allow_writeable_chroot=YES
connect_from_port_20=YES
pam_service_name=vsftpd
seccomp_sandbox=NO
ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=NO
force_local_logins_ssl=NO
require_ssl_reuse=YES
ssl_ciphers=HIGH
pasv_enable=YES
pasv_promiscuous=YES
pasv_address=192.168.49.3
pasv_min_port=30000
pasv_max_port=30000
rsa_cert_file=/etc/ssl/certs/vsftpd.crt
rsa_private_key_file=/etc/ssl/private/vsftpd.key
13 changes: 13 additions & 0 deletions srcs/ftps/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

openssl req -newkey rsa:2048 -x509 -days 365 -nodes \
-keyout /etc/ssl/private/vsftpd.key \
-out /etc/ssl/certs/vsftpd.crt -subj \
"/C=BR/ST=Sao Paulo/L=Sao Paulo/O=42SP, Inc./OU=IT/CN=ft_services"

#In this case, the User and Password are related to the VM used to correct the project.
mkdir -p /var/ftp
adduser -D -h /var/ftp $USERNAME
echo "$USERNAME:$PASSWORD" | chpasswd

vsftpd /etc/vsftpd/vsftpd.conf
13 changes: 13 additions & 0 deletions srcs/grafana/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM alpine:3.11.6

WORKDIR /usr/share/grafana

RUN apk update
RUN apk add grafana \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/

COPY dashboards/ /usr/share/grafana/public/dashboards/

EXPOSE 3000

ENTRYPOINT ["/usr/sbin/grafana-server", "web"]
130 changes: 130 additions & 0 deletions srcs/grafana/dashboards/ftps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": 5,
"links": [],
"panels": [
{
"datasource": null,
"fieldConfig": {
"defaults": {
"custom": {},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 12,
"x": 0,
"y": 0
},
"id": 2,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"mean"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "7.3.0",
"targets": [
{
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "kubernetes_pod_container",
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"restarts_total"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": [
{
"key": "container_name",
"operator": "=",
"value": "ftps"
}
]
}
],
"timeFrom": null,
"timeShift": null,
"title": "Restarts Total",
"type": "stat"
}
],
"schemaVersion": 26,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "ftps",
"uid": "3j9b2k2Gk",
"version": 4
}
Loading

0 comments on commit fffca32

Please sign in to comment.