
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
最新评论
照片令人惊艳。万分感谢 温暖。
氛围绝佳。由衷感谢 感受。 你的博客让人一口气读完。敬意 真诚。
实用的 杂志! 越来越好!
又到年底了,真快!
研究你的文章, 我体会到美好的心情。
感谢激励。由衷感谢
好久没见过, 如此温暖又有信息量的博客。敬意。
很稀有, 这么鲜明的文字。谢谢。