Code Monkey home page Code Monkey logo

k8s-review's Introduction

Kubernetes測試報告

  • 本專案主要針對kubernates的教學進行學習、測試以及紀錄
  • 建立Spring boot專案
  • 產生docker image
  • 使用kubernetes minikube對外溝通

Tutorials Website

Tool Install

  • Minikube
brew install minikube
brew install kubectl

Usage

  1. 下載上述工具
  2. 打開Spring boot專案
  3. 使用Maven install產生target資料夾HappyDemo-0.0.1-SNAPSHOT.jar
  4. 新增docker file(如下)
  5. 修改image tag 為自己docker account/app名字(lnc2244/happy-demo)並產生local image
  6. push to repository

(terminal)

  1. 開啟minikube 並create deployment(pod)
minikube start

minikube start 8. 編輯.yaml檔案以產生deployment/pods(如下)

  1. 啟用.yaml檔案
kubectl apply -f happy-app-deployment.yaml
  1. 檢查pods中的application是否正常運作
kubectl logs [pods name]

kubectl-logs 11. 創建Serivce 讓pods可與外部溝通

minikube tunnel
kubectl expose deployment happyapp --name=happyapp-service --port --target-pirt=8080 --type=LoadBalancer

kubectl expose

  1. 取得對外溝通localhost
minikube service happyapp-service --url 
--> http://127.0.0.1:56506

get url 13. 在瀏覽器中輸入[localhost]/[springboot url] final demo

Docker file

FROM openjdk:17-jdk
VOLUME /tmp
COPY target/HappyDemo-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT ["java", "-jar", "/app.jar"]

happy-app-deployment.yaml

kind: Deployment
apiVersion: apps/v1
metadata:
  name: happyapp
  labels:
    app: happyapp
spec:
  replicas: 2
  selector:
    matchLabels:
      app: happyapp
  template:
    metadata:
      labels:
        app: happyapp
    spec:
      containers:
        - name: happy-demo
          image: lnc2244/happy-demo
          ports:
          - containerPort: 80

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.