Git Product home page Git Product logo

k8s-demo's Introduction

k8s-demo

These are steps as shown in my Kubernetes demo. Clone this repo and use it for your own testing.

These steps assume you have a Route 53 domain and hosted zone already. If not, see the AWS Documentation here

This also assumes you have a public SSL certificate in ACM that covers your domain name and wildcard domain name (such as example.com and *.example.com). These steps are documented here. Note the certificate must be in the same region as your planned EKS cluster deployment. Make note of the ARN for your certificate as it is needed later.

Step 1 - Install EKS

This is covered in AWS documentation here.

Install eksctl

  • On Linux
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin
eksctl version
  • On Mac
brew tap weaveworks/tap
brew install weaveworks/tap/eksctl
eksctl version 
brew upgrade eksctl && brew link --overwrite eksctl

Update external-dns in your repo to reflect your domain name

vi manifests/kube-system/external-dns.yaml
--domain-filter=Your-Domain.com  

Deploy your cluster

There is already a cluster.yaml template in this directory you can use.

eksctl create cluster -f cluster.yaml
kubectl get nodes

Add Weave Flux for GitOps

Weave Flux runs in a Kubernetes cluster and monitors your git repos for changes. It will apply manifests as they change. It can also monitor your Docker registry and deploy any image changes.

Update te git-url and git-email below to reflect your environment before running.

# Create a deploy key (used by Flux) and upload to your cluster
ssh-keygen -q -N "" -f weave-flux-deploy-key

kubectl create ns flux 
kubectl create secret generic flux-git-deploy --from-file=identity=weave-flux-deploy-key -n flux 

# Install Flux (from eksctl) 
EKSCTL_EXPERIMENTAL=true \
    eksctl enable repo \
        --git-url [email protected]:jonjozwiak/k8s-demo \
        --git-email [email protected] \
        --git-paths=manifests \
        --cluster eks1 \
        --region us-west-2

In GitHub, go to your repo and add a deploy key as follows:

  • In GitHub go to 'Settings' for the repo (NOT YOUR OVERALL PROFILE)
  • Click 'Deploy Keys' and 'Add deploy key'
  • Title: Weave Flux Deploy Key
  • Key: Paste your weave-flux-deploy-key.pub
  • Click the 'Allow Write Access' and click 'Add Key'

Within 5 minutes this will deploy your base manifests.

Demo Steps for a simple Python Flask App

See the steps in my hello-python repo

Demo Steps for a simple nginx web server

My web server is already deployed as it is defined in the manifests here. Update the source code at hello-nginx repo and you will see the new version deployed within 5 minutes.

Monitor by looking at the following:

kubectl get pods   # Look for new deployment time in seconds

kubectl get pods -n flux 
kubectl logs flux-######-##### -n flux
 1568  kubectl get pods 
 1569  git pull
 1570  git log --oneline 
 1571  git revert HEAD 
 1572  git log --oneline
 1573  git push 

Roll back to the previous version using Git in your hello-nginx repo

# In your hello-nginx directory
kubectl get pods
git pull
git log --oneline
git revert HEAD
git log --oneline
git push

# Wait up to 5 minutes
kubectl get pods 

# Connect in https://nginx.redhatapps.com

Cleanup

eksctl delete cluster -f cluster.yaml

k8s-demo's People

Contributors

jonjozwiak avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.