Skip to content

sejoonkimmm/Inception-of-things-IoT-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Inception-of-things-IoT-

42Seoul Outer-circle Project

image

Project Title: Inception-of-Things (IoT)

General

This project aims to provide a hands-on experience with Kubernetes, using K3s, K3d, and Argo CD. It is structured into three mandatory parts and an optional bonus part, focusing on setting up and deploying web applications in a Kubernetes environment.

General Guidelines

The project must be completed in a virtual machine. Configuration files should be placed in root directories: p1, p2, p3, and bonus for the bonus part. It is recommended to read extensively on K8s, K3s, and K3d for a comprehensive understanding.

Project Setup

Prerequisites

VirtualBox or any preferred VM provider. Vagrant for virtual machine management. Docker for containerization. Kubectl for interacting with the Kubernetes cluster.

Installation

Virtual Machine Setup: Use Vagrant to set up two virtual machines. Refer to the Vagrantfile examples provided for configuration details. K3s Installation: Install K3s on both VMs, configuring one as a server and the other as an agent. K3d and Argo CD: Install K3d on your host machine and set up Argo CD for continuous integration.

Usage

Part 1: K3s and Vagrant

Initialize two VMs with Vagrant, setting up K3s with the server-agent model.

Part 2: K3s and Three Simple Applications

Deploy three web applications accessible via different hostnames, using K3s on a single VM.

Part 3: K3d and Argo CD

Transition to a K3d environment, implementing CI/CD with Argo CD for automated deployment from a GitHub repository.

Instruction

Part 1

Type

vagrant up --provider=virtualbox

This command launches two virtual machines. One serves as the master node and the other as a worker node. During the setup of the master node, a token provided as an option allows the worker node to connect to the master node.

and ssh login to Master node

vagrant ssh sejokimS

and Type this command

kubectl get nodes -o wide
image

K3s cluster setup is complete.

Part 2

Based on the requested host header, the traffic is routed to different domain names: sejokimapp1.com, sejokimapp2.com, and sejokimapp3.com.

You'll need to write the ingress, service, and deployment YAML files to configure Kubernetes.

Ingress Ingress is an API object in Kubernetes that routes HTTP/HTTPS requests from outside the cluster to services within the cluster. It acts like a gateway, directing incoming requests to the appropriate services.

Here is an example of an Ingress configuration:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress
spec:
  rules:
  - host: sejokimapp1.com
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: app1-service
            port:
              number: 80
  - host: sejokimapp2.com
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: app2-service
            port:
              number: 80
  - host: sejokimapp3.com
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: app3-service
            port:
              number: 80

The metadata section includes information to identify and describe the Ingress object. The spec section defines the actual rules for routing traffic based on domain names to specific services.

Deployment Deployment is used to declaratively update applications. It ensures that the specified number of Pods are running and recreates Pods as necessary to maintain the desired state.

Here's a brief on what Deployment looks like, although it’s a deep topic worthy of further exploration separately.

Service Service defines a way to access Pods reliably within the internal network. It can act as a load balancer, distributing incoming requests to all Pods linked to the Service.

YAML File All Kubernetes configuration files generally include three main sections:

metadata: Provides names and descriptions to distinguish components. spec (specification): Applies detailed settings based on the type of component. status: Automatically created and updated, it shows the desired and actual state, enabling Kubernetes' self-healing capabilities. To create Pods, a Deployment is necessary, which maintains them reliably. Connecting a Service and a Deployment involves matching labels in the Deployment’s metadata with those specified in the Service's selector.

Here's a basic connection approach:

spec:
  selector:
    matchLabels:
      app: nginx

This matches with the Deployment where the app: nginx label is set, ensuring the Service routes traffic to the correct Pods.

Screen Shot 2024-04-23 at 5 26 10 PM Screen Shot 2024-04-23 at 5 25 32 PM Screen Shot 2024-04-23 at 5 25 26 PM Screen Shot 2024-04-23 at 5 25 17 PM

Part 3

Type

sh scripts/init_docker_k3d.sh

To install Docker, Kubernetes, and k3d and then create a k3d cluster

sh scripts/deploy.sh

To install Argo CD on a Kubernetes cluster and set it up so you can access it from localhost:8081, and to configure the admin password to be output to the terminal

Screen.Recording.2024-04-23.at.5.35.28.PM.mov

About

42Seoul Outer-circle Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages