K8s
New Infrastructure
To setup new AWS infrastructure, follow below steps:
- To create base infrastructure using Magikube please refer Create Project guide.
- Select
aws
from the options inSelect a Cloud Provider
prompt. - If you have setup a default region then
Select a Region
will show it. If that is the region you want to use then move to next step, otherwise you can change to region of your choice. - Use
k8s
forSelect a Cluster Type
. - Validate or update AWS profile name to be used in
Enter AWS profile to use
. - Select your code repository provider in
Source code repository
. - If AWS profile name does not exist then
magikube
will create a new profile with you. It will needAWS Access Key ID
andAWS Secret Access Key
. - Which environment are you creating. Make selection in
Select an Environment
. - If you are creating a
non-production
environment, then select one or more lifecyles inSelect Lifecycle(s)
. - Enter a domain name in the
Enter the Domain Name
prompt. - To create applications, please refer Apps Guide.
Post Deployment Setup for K8s
- Using terminal ssh into your master server using command
ssh {{ project_name }}-{{ environment }}-master
- Execute command to get the list of namespaces
kubectl get namespace
- Execute command to list all the service running
kubectl get svc -n {{ project_name }}-{{ environment }}-app
- Execute command and fetch the frontend(Eg: react) IP Value. Here frontend_app is the name of frontend service from step 3.
kubectl get {{ frontend_app }} -n {{ project_name }}-{{ environment }}-app -o jsonpath='{.spec.clusterIP}'
- Create a file i.e. /etc/nginx/sites-available/application-nginx.conf
using below content and replace the value for
{{ hostname }} and {{ frontend_service_ip }}
## server configuration for Application
server {
listen 80;
server_name {{ hostname }};
if ($http_x_forwarded_proto = '') {
set $http_x_forwarded_proto $scheme;
}
## Application specific logs
chunked_transfer_encoding on;
client_max_body_size 0;
location / {
proxy_read_timeout 2400s;
proxy_pass_header Server;
proxy_cookie_path ~*^/.* /;
proxy_pass http://{{ frontend_service_ip }}:80;
proxy_next_upstream error timeout non_idempotent;
proxy_next_upstream_tries 1;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
- Create a symlink for the nginx configurations using command
sudo ln -s /etc/nginx/sites-available/application-nginx.conf /etc/nginx/sites-enabled/application-nginx.conf
- Restart Niginx using command
sudo systemctl reload nginx
Destroy Project
To destroy infrastructure and applications, created using magikube
please refer Destroy Project guide.