k8s-template/README.md

3.7 KiB

k8s-template

What is this?

You can use this template when you create a new lab and deploy it to kubernetes.

Sample Workflow

  • Alice : Content Creator
  • Bob : Lab Administrator

1. Servers vs Clients

Alice ->> Bob: I'd like to create a new lab for ION.
Bob ->> Alice: Do you want servers or clients? 
Alice ->> Bob: I just need a web server that will be shared by learners.

Bob can create diverse types of servers (Linux only!) such as, web servers, application servers, and database servers.

Sample server: https://origin-akashop.akamai-lab.com/

Bob can create one type of clients based on Visual Studio Code. Clients can be assigned to learners one to one or one to many.

Sample client: https://training.akamai.com/ewp

2. Software

Bob ->> Alice: Do you have any prefered web server software, like apache or nginx?
Alice ->> Bob: nginx would be good. 
Bob ->> Alice: Do you need any other softwares?
Alice ->> Bob: Yes. Please install python3. And I have my own web content files.(html, css, js, images,...)

Bob can install other softwares or tools such as akamai cli, based on the lab scenario.

Alice's files will be copied to kubernetes volume(s) later.

3. Infrastructure

Bob ->> Alice: We use Kubernetes for labs by default. Would it be ok with you?
Alice ->> Bob: What other choices do I have?
Bob ->> Alice: You can select a virtual machine or docker. However, Kubernetes is better when it comes to availability and scalability.
Alice ->> Bob: Alright. I will go with Kubernetes.

Bob will use Kubernetes unless Alice has a compelling reason to use other infrastructure.

4. Docker Image

Bob ->> Alice: Do you have a custom docker image for this lab?
Alice ->> Bob: No.  
Bob ->> Alice: OK. Then I will build a docker image based on public nginx docker image.

Bob builds a docker image and Alice validates it iteratively until they finalize the image. They might need more discussion on the technical details such as, HTTPS, FQDN, port, and etc.

The docker image is not deployed to Kubernetes in this stage.

5. Staging

Bob builds kubernetes yaml files and Alice validates them iteratively until they finalize the yaml files. They might need more discussion on the technical details such as health check, auto scaling, persistent volume, and etc.

The yaml files are applied to Kubernetes staging environment.

All files (Dockerfile, Alice's files, yaml files) are saved in Gitea repository. (https://gitea-ptl.akamai-lab.com)

6. Production

Bob clones the Gitea project and applies all files to kubernetes production environment.

git clone https://gitea-ptl.akamai-lab.com/akamai/k8s-template.git
cd traefik
kubectl apply -f 00-account.yml -f 00-role.yml -f 01-role-binding.yml -f 02-traefik.yml -f 02-traefik-services.yml
  
cd ../nginx
kubectl apply -f nginx-deployemt.yml -f nginx-service.yml -f nginx-ext.yml -f nginx-ingress.yml -f pv.yml -f pvc.yml

Alice validates the environment by end-to-end test.

More Sample Codes

How to use HTTPS

How to redirect HTTP to HTTPS

How to maintain Session Stickyness

How to use ReadWriteMany pvc