专注于分布式系统架构AI辅助开发工具(Claude
Code中文周刊)

Kubernetes Essentials - Starting Your Journey with K8S - Lesson 01

智谱 GLM,支持多语言、多任务推理。从写作到代码生成,从搜索到知识问答,AI 生产力的中国解法。

![]([object Object])
Dive into the world of Kubernetes with our comprehensive guide, 'Kubernetes Essentials: Starting Your Journey with K8S – Lesson 01'. This introductory lesson is tailored for beginners and offers a detailed overview of Kubernetes' basic concepts, architecture, and its role in modern cloud computing. Discover how Kubernetes revolutionizes container orchestration, simplifying deployment, scaling, and management of containerized applications. This article is the perfect starting point for anyone looking to build a strong foundation in Kubernetes.

Build Helloworld.go

package main

import (
    "fmt"
    "log"
    "net/http"
)

func handler(w http.ResponseWriter, r *http.Request) {
    log.Println("received request from", r.RemoteAddr, r.URL.Path[1:])
    var welcome = r.URL.Path[1:]
    if len(welcome) == 0 {
        welcome = "World"
    }
    fmt.Fprintf(w, "Hello, %s! ", welcome)
}

func main() {
    http.HandleFunc("/", handler)
    log.Println("starting server on port 9000")
    log.Fatal(http.ListenAndServe(":9000", nil))
}

Make Dockerfile

FROM golang:latest

# 将工作目录设置为 /app
WORKDIR /app

# 将当前目录下的所有内容复制到 /app 下
COPY . /app

# 允许宿主机访问容器的 8000 端口
EXPOSE 9000

# 设置容器进程为:go run helloworld.go
CMD go run helloworld.go

Build Image

docker build -t helloworld:1.0 .

Start container

docker run -d --name myhello -p 9000:9000 helloworld:1.0
赞(0)
未经允许不得转载:Toy Tech Blog » Kubernetes Essentials - Starting Your Journey with K8S - Lesson 01
免费、开放、可编程的智能路由方案,让你的服务随时随地在线。

评论 抢沙发

十年稳如初 — LocVPS,用时间证明实力

10+ 年老牌云主机服务商,全球机房覆盖,性能稳定、价格厚道。

老品牌,更懂稳定的价值你的第一台云服务器,从 LocVPS 开始