肛门塞什么东西最舒服| 痛风吃什么| 好马不吃回头草什么意思| 凌空什么什么| 乳贴是什么| 梗阻性黄疸是什么病| 什么叫肾阳虚肾阴虚| 晚上12点是什么时辰| 为什么会拉血| 72年属什么生肖| 太妃是皇上的什么人| 财政部部长什么级别| 智齿什么时候长| 便秘吃什么有用| 眼压高用什么药| 全程c反应蛋白高说明什么| 嘴角上扬是什么意思| 尿道感染看什么科| 心阳不足吃什么中成药| 图字五行属什么| 火龙果对身体有什么好处| 大便羊屎粒是什么原因| 什么饭不能吃| 熙熙攘攘是什么意思| 服化道什么意思| 菩提子手串有什么好处| hl是什么意思| 公务员是什么编制| mra是什么意思| 雪里红是什么| 血小板计数偏高是什么原因| 敏五行属什么| 皮肤越抓越痒是什么原因| 贝母和川贝有什么区别| 原来是什么意思| 什么是过敏性咳嗽| 未加一笔是什么字| 别开生面什么意思| 心境障碍是什么病| 脱臼是指什么从什么中滑脱| 膀胱尿潴留是什么意思| 中国一词最早出现在什么时候| 血月代表什么| 阴阳两虚吃什么药| 梦见抽血是什么预兆| 身体缺钾是什么原因造成的| 心律失常是什么意思| 碳化是什么意思| 梦见穿袜子是什么意思| 体寒吃什么| 前列腺彩超能查出什么| 驳什么意思| 失眠是什么| 肠管积气是什么原因| 神经官能症是什么病| 水解奶粉是什么意思| 埃及法老是什么意思| 男人送女人项链代表什么| 空调干燥是什么意思| 抓兔子的狗叫什么名字| 婴儿蓝是什么颜色| 积家手表什么档次| 油菜花像什么| 9点到11点是什么经络| yg是什么意思| 过度换气是什么意思| 大饼是什么意思| 什么手机最好用| 世界上最多笔画的字是什么字| 西瓜有什么功效| 脑梗是什么病严重吗| 属马女和什么属相最配| 什么蛋| 滇红属于什么茶| 手一直脱皮是什么原因| 荸荠的读音是什么| 50年属什么生肖| 内蒙古有什么特产| 孕妇吃鸡蛋对胎儿有什么好处| 尖湿锐吃什么药最好| 朋友梦到我怀孕了是什么意思| 跳蚤吃什么| 什么是色弱| 早晨起床口干口苦是什么原因| 阅兵什么意思| 物理压榨油是什么意思| 潮汕立冬吃什么| 罹患率是什么意思| 头抖是什么原因| 电场是什么| 双性人什么意思| 脸上痒是什么原因| 导诊是干什么的| 为什么人会衰老| 助教是干什么的| 窥见是什么意思| 风疹是什么症状| 蛇蝎心肠是什么生肖| 高晓松为什么进监狱| 青蛙趴有什么好处| 心脏缺血吃什么药最好| 螺内酯片治什么病| 总胆固醇是什么| 淋巴结肿大吃什么药消肿效果好| 正常舌头是什么颜色| 甲钴胺片治疗什么病| 做亲子鉴定需要什么材料| 贡中毒有什么症状| 猫吃什么| 腹泻挂什么科| 有张有弛是什么意思| 缺血吃什么补血最快| 亲嘴为什么要伸舌头| 心脏不好挂什么科室| 娣什么意思| 一进去就射是什么原因| 7月20号是什么星座| 全会是什么意思| 双肾尿酸盐结晶是什么意思| cancer是什么意思| 米醋和陈醋有什么区别| 痉挛是什么症状| grace什么意思中文| 睾丸疼什么原因| 兄长是什么意思| 急性痛风吃什么药| 耳石症是什么原因| 两个土念什么| 鼻腔干燥是什么原因| 麻叶是什么植物| 嗜睡是什么原因| 深耕是什么意思| lotus是什么车| 咽炎吃什么药好使| 情商是什么意思| 吃什么头发长得快| 什么花适合送老师| 慕名而来是什么意思| 绿色裤子配什么上衣| 陌上花开可缓缓归矣什么意思| 鸡蛋可以炒什么菜| 飞机下降时耳朵疼是什么原因| 世界上最大的动物是什么| 曹操是什么生肖| 嬴荡和嬴政什么关系| 西瓜什么时候种植| 四川代表什么生肖| 胰岛素是什么意思| 什么的旅行| 80年属什么生肖| 近字五行属什么| 双龙戏珠是什么意思| 炖鸡汤用什么鸡| 胃疼吃什么药最有效| 缺钾是什么症状| 三手烟是什么意思| 药店属于什么行业| 傻白甜是什么意思| 梦见蛇被别人打死是什么兆头| 庙祝是什么意思| baron是什么意思| 类风湿关节炎吃什么好| 厌男症的表现是什么| 肺上有结节是什么病| 桑树枝煮水有什么功效| 梅毒和艾滋病有什么区别| 肺部散在小结节是什么意思| 白塞氏病是什么病| 胃疼检查什么项目| 依波手表什么档次| 什么叫物质女人| 盗墓笔记的结局是什么| 包二奶什么意思| 指甲上的白色月牙代表什么| 什么钻进风箱里两头受气| 舒字五行属什么的| d代表什么| 入职体检挂什么科| 上面一个处下面一个日是什么字| 体检胸透主要检查什么| 坏是什么意思| 人中深浅代表什么| 小儿外科主要看什么病| 眼球有黑色斑点是什么| 银杏叶提取物治什么病| 睾丸癌是由什么引起的| 心属于五行属什么| 鼻塞打喷嚏是什么原因| 助产是干什么的| 化验血能查出什么项目| 月经一直不干净吃什么药| 末梢血是什么意思| lgg什么意思| 什么降血糖| 踏雪寻梅是什么意思| 什么是叶酸| 酸菜吃多了有什么危害| 女人吃什么补肾| pdr是什么意思| buffalo是什么牌子| 什么叫双向情感障碍| 疱疹是什么原因长的| 小孩咳嗽吃什么药效果最好| 铁皮石斛治什么病| 农历九月五行属什么| 早期教育是什么| 后背疼痛什么原因| phicomm是什么牌子| 什么是夫妻宫| 金骏眉属于什么茶| 失态是什么意思| 肾不好是什么原因引起的| 喉咙发炎咳嗽吃什么药好得快| 社保卡是什么意思| 转氨酶偏高是什么原因引起的| 什么货币最值钱| 指骨属于什么骨| 牙龈有点发黑是什么原因| 纯爱是什么意思| 什么药可以降尿酸| 20至30元什么烟最好抽| 66年属马的是什么命| 什么是学前教育| 1月30号是什么星座| 三点水一个分读什么| 为什么脖子老是痒| 清关是什么意思| 大理寺是什么机构| 破釜沉舟的釜是什么意思| 膝关节退行性改变是什么意思| 生菜是什么菜| 月经血块多是什么原因| 丙火是什么意思| 爱的意义是什么| 生男孩女孩取决于什么| 哺乳期吃什么奶水多| h代表什么单位| 吃什么好消化| 艾灸是什么东西| 纠结是什么意思| 铅笔为什么叫铅笔| 喉咙痒是什么原因| 什么叫法令纹| 丝瓜水敷脸有什么作用| 新生儿用什么奶粉好| 姜还是老的辣是什么意思| ua是什么意思| 西辽国在现今什么地方| 正常小便是什么颜色| 离宅是什么意思| 什么是混合物| 灵芝有什么作用与功效| 中国最大的湖泊是什么湖| 头部MRI检查是什么意思| 三七粉适合什么人群喝| 若叶青汁有什么功效| 空调什么牌子的好| 结缡什么意思| 医学上ca是什么意思| 甲状腺炎有什么症状表现| 芋圆是什么做的| 玫瑰茄是什么东西| 奢侈的近义词是什么| 年轻人长老年斑是什么原因| 百度

百度 随后,全国各地方社院纷纷创立,1961年社会主义学院改名为中央社会主义学院。

Validated on 18 Apr 2022 ? Last edited on 17 Apr 2025

DigitalOcean Kubernetes (DOKS) is a Kubernetes service with a fully managed control plane, high availability, and autoscaling. DOKS integrates with standard Kubernetes toolchains and DigitalOcean’s load balancers, volumes, CPU and GPU Droplets, API, and CLI.

In this tutorial, you create an app, build it as a Docker image, and run it on a DigitalOcean Kubernetes cluster. You also learn how to use DigitalOcean Container Registry to store your Docker images for use in your cluster.

Prerequisites

To follow this tutorial, you must:

STEP 1: Authenticate Your Environment

First, generate a token with read and write access, using any name of your choice. The token is only displayed once, so save it somewhere safe.

Use the following command to authenticate doctl. Paste in your token when prompted.

doctl auth init

STEP 2: Build a Sample Python App

Create a sample app that outputs a “Hello World!” message and its hostname to the screen.

In a new directory, create a app.py file with and write the following content:

app.py
from flask import Flask
import os
import socket

app = Flask(__name__)

@app.route("/")
def hello():
    html = """Hello {name}!
    Hostname: {hostname}"""
    return html.format(name=os.getenv("NAME", "world"), hostname=socket.gethostname())

if __name__ == "__main__":
    app.run(host='0.0.0.0', port=80)

This code uses the Flask web framework to create a web server that listens on port 80. When you visit the server in a browser, it returns a “Hello World!” message and the hostname of the machine serving the request. The NAME environment variable is used to customize the message. If NAME is not set, it defaults to “world”. This variable is set in the next step.

Create a requirements.txt file with the following content. In the next step, the Docker image configuration uses this file to install Flask as the one Python dependency for your app.

requirements.txt
Flask

STEP 3: Build a Docker Image

To build a Docker image, you first need to create a Dockerfile. A Dockerfile is a text document that defines the environment, build, and run commands that your code needs to run. Executing a Dockerfile creates a build artifact called an image.

The ability to compose environments this way with a Dockerfile is a significant benefit of using containers. With an image, code is bundled with the environment it needs to run, which solves the problem of getting code to run correctly in different environments, like on different machines.

In the same directory, create a file called Dockerfile and write the following content:

Dockerfile
# Use an official Python runtime as a parent image. 
FROM python

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
ADD . /app

# Install any needed packages specified in requirements.txt
RUN pip install -r requirements.txt

# Make port 80 available to the world outside this container
EXPOSE 80

# Define environment variable
ENV NAME World

# Run app.py when the container launches
CMD ["python", "app.py"]

The commands in this Dockerfile define an environment with Python set up and Flask installed via pip, move the app’s code to where Flask expects it, define the NAME environment variable that the app needs, open HTTP port 80 to the world, and define the command that runs your app.

Run the following command to build an image based on the Dockerfile you defined. Tag it with -t so it has a human-readable name:

docker build -t my-python-app .

Once built, Docker images are stored in a registry, which is a collection of images. You can use the docker images command to see the images you have locally.

docker images

Use the following command to run the image. The -ti arguments ensure you can enter CTRL/CMD+C to exit, and the -p argument maps port 80 of the container to port 80 of the host machine, so you can reach the web server from your browser:

docker run -ti -p 80:80 my-python-app

Go to http://localhost in your browser to see the output of your app. It displays the “Hello World!” message and the hostname of the machine serving the request. You are now accessing your app from a container, which is a runtime instance of the image. Docker returns the ID of the container for a hostname, simulating how a virtual machine might slot in the machine hostname. Therefore, each time you run the image, you get a new container, and therefore a new hostname.

Enter CTRL/CMD+C in your terminal to exit the app. Then, run the app again:

docker run -ti -p 80:80 my-python-app

The hostname changes, demonstrating that the image is the immutable artifact that contains your app, and the container is an ephemeral runtime instance of that image.

STEP 4: Upload Your Docker Image

The image is still only in your local registry. To make it available to other machines, you need to upload it to a registry server.

Since you have already authenticated your environment with your DigitalOcean account, you can create such a registry with DigitalOcean Container Registry (DOCR). Run the following command using your registry name for the <your-registry-name> variable:

doctl registry create <your-registry-name>

Then, log in to your registry with this commend. This configures Docker to use DOCR as the default registry for pushing and pulling images:

doctl registry login

Next, tag your image with the fully-qualified name of your registry, which tells Docker where to upload it:

docker tag my-python-app registry.digitalocean.com/<your-registry-name>/my-python-app

Finally, push your image to the registry:

docker push registry.digitalocean.com/<your-registry-name>/my-python-app

Once uploaded, you can use the following command to create a running container of your app on any machine that you have authenticated your environment on (with doctl registry login):

docker run -p 80:80 registry.digitalocean.com/<your-registry-name>/my-python-app

STEP 5: Create a Cluster

Now that you have a containerized version of your app stored in a cloud registry, you can run it on Kubernetes at scale using DigitalOcean Kubernetes, which provides a management layer that offers convenience features like automatic upgrades, monitoring, security patches, metrics, logging, and a user interface for managing your cluster.

From one image you can create many containers, and to run at scale, you need something like Kubernetes to manage them, which is an orchestrator. An orchestrator is a management application that coordinates running containers on a cluster of machines. Each machine in a cluster is called a node. In DigitalOcean Kubernetes, these nodes are Droplets. If your app needs more capacity, you can add more nodes to your cluster. Kubernetes then packs them efficiently with your containers, managing their state and secrets for you.

DigitalOcean Kubernetes gives users the ability to manage groups of nodes in tandem using node pools, which are groups of nodes that you configure to be of a certain size and number. If enabled, node pools auto-scale, increasing or decreasing the number of nodes when their resources are over or underutilized. You can also configure node pools to automatically upgrade their nodes to the latest patch version of Kubernetes.

Create a new DigitalOcean Kubernetes cluster with the following command:

doctl kubernetes cluster create <your-cluster-name> --tag do-tutorial --auto-upgrade=true --node-pool "name=mypool;count=2;auto-scale=true;min-nodes=1;max-nodes=3;tag=do-tutorial"

This command creates a cluster with one node pool named mypool featuring two nodes to start. It also allows the cluster to automatically scale the node pool in size between one and three nodes (depending on the needed capacity). Finally, it tags everything with do-tutorial, and enables automatic upgrades to keep the cluster up to date with security patches and upgrades.

Note
During the cluster creation process, doctl automatically configures the Kubernetes command-line interface, kubectl, so that all kubectl commands execute against your new cluster. This is similar to how doctl registry login configured the docker CLI to use your new registry. Therefore, you can use the kubectl commands in this tutorial to manage your cluster without further configuration. If you need to manage a different cluster, you can change kubectl’s context using doctl kubernetes cluster kubeconfig.

There are a number of machine sizes you can use for a node, each one offering a different combination of memory and CPU cores. When creating a node pool, you can configure machine size using any slug returned from the doctl kubernetes options sizes command or on the Droplet pricing page. If you change the desired machine size after creating the node pool, DigitalOcean Kubernetes recycles the nodes, which destroys the old nodes at the same rate as they are being replaced with the new ones.

STEP 6: Run Your App on a Cluster

Your cluster is ready when you get output that looks like this:

Notice: Cluster is provisioning, waiting for cluster to be running
......................................................
Notice: Cluster created, fetching credentials
Notice: Adding cluster credentials to kubeconfig file found in "/root/.kube/config"
Notice: Setting current-context to do-nyc1-*********

The components of a Kubernetes cluster are defined by YAML files called manifests. A common Kubernetes workflow is a cycle of defining or modifying a manifest and then applying it to a cluster with kubectl apply.

Here, the next step is authorizing your cluster to use your private registry so it can download images. You can use doctl to generate the manifest for this, and then pipe the generated manifest directly to kubectl to apply it:

doctl registry kubernetes-manifest | kubectl apply -f -

Kubernetes stores your registry credentials as a secret, the built-in mechanism Kubernetes offers for securely storing sensitive data. After running this command, the secret is uploaded and given a name similar to your registry’s name.

Next, configure Kubernetes to use this secret as an authentication token when pulling images from your private registry:

kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "registry-<your-registry-name>"}]}'

Finally, you can deploy the app. To create a Deployment of your app, which is the object Kubernetes uses to maintain the desired state of your running containers, run the following command. This launches the app live in the cluster:

kubectl create deployment my-python-app --image=registry.digitalocean.com/<your-registry-name>/my-python-app

Each deployment creates a replica set, which is the object Kubernetes uses to maintain a stable number of replicas of your container. Each replica is a separate running instance of your container called a pod. Replica sets track the desired number of pods you wish to run for your app. By default, this is set to one, as you see when you run this command:

kubectl get rs
NAME                       DESIRED   CURRENT   READY   AGE
my-python-app-84b997f5b4   1         1         1       5s

To view details at the pod level, run the following command:

kubectl get pods
NAME                             READY   STATUS             RESTARTS   AGE
my-python-app-84b997f5b4-6j5pn   1/1     Running              0          27s

Try scaling up to run 20 replicas:

kubectl scale deployment/my-python-app --replicas=20

Now, when you call kubectl get rs and kubectl get pods, you see a lot more activity. If you repeatedly call kubectl get pods, you can watch the Status column change as Kubernetes gets the 19 new pods up and running.

Next, run the following command to see how these Pods get divided over your nodes:

kubectl get pod -o=custom-columns=NODE:.spec.nodeName,NAME:.metadata.name --all-namespaces | grep my-python-app

This returns an output similar to the following:

mypool-byrky   my-python-app-84b997f5b4-25shx
mypool-byrky   my-python-app-84b997f5b4-2tkgz
mypool-zrkyz   my-python-app-84b997f5b4-5dtbz
mypool-zrkyz   my-python-app-84b997f5b4-5gl7h
...

Since you named your node pool mypool, the two individual nodes have names with mypool, plus some random characters. Furthermore, the pods are being scheduled so that they are comfortably spread out on your available capacity.

Next, create a load balancer to expose your deployment to the world. The load balancer runs in the cloud and routes the incoming traffic:

kubectl expose deployment my-python-app --type=LoadBalancer --port=80 --target-port=80

This command exposes the pods to the world behind a load balancer, which receives traffic at port 80 and routes that traffic to port 80 on the pods, mapping the host and container ports similarly to how the -p flag was used when testing the app with Docker.

Keep running this command until you see active under the Status column for the new load balancer:

doctl compute load-balancer list --format Name,Created,IP,Status

This returns an output similar to the following:

Name                                Created At              IP                 Status
a55a6520a74d5437fa389891f2f8708f    2025-08-07T14:46:34Z    143.244.215.xxx    new
Note
When you first run this command, the Status is new and the IP is blank; re-run the command until you have been assigned an IP address.

Navigate to the IP address of the load balancer and refresh your browser. The hostname you used earlier changes with every refresh, cycling between the container IDs. This confirms that you have multiple healthy Pods running and serving traffic in a load-balanced way.

STEP 7: Check the Kubernetes Dashboard

You can use the Kubernetes dashboard to inspect your cluster and view visualizers and graphs of your cluster’s state. Install the 1-Click App and then port-forward the dashboard to your local machine to access it.

Summary

You created a sample app, built a Docker image of it, created a private registry, uploaded your image, created a cluster, deployed your application to it, scaled your app up 20x, and exposed it to the world over a load balancer, making it accessible at a stable IP address.

What’s Next

Now that you know the basics, we recommend reading the Kubernetes Operational Readiness Guide to learn how to set up tools such as nginx and Cert-Manager to make your cluster operationally ready to serve production traffic over HTTPS.

We also recommend that you set up push-to-deploy with the official DigitalOcean GitHub Action to automatically build and deploy your code to your cluster when you push to your GitHub repository.

Finally, we recommend learning how to configure auto-scaling for your cluster when resources are over or underutilized.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.

红苕是什么 治疗白斑最有效的方法是什么 产后漏尿是什么原因 火鸡面是什么 和田玉和翡翠有什么区别
桃对什么 什么人容易得圆锥角膜 什么食物黄体酮含量高 翡翠的种水是什么意思 综艺是什么意思
万马奔腾是什么生肖 老舍的原名是什么 六月初一什么日子 疱疹性咽峡炎吃什么食物 污秽是什么意思
血管瘤是什么样子的图 有什么水能代替美瞳水 懋是什么意思 优甲乐什么时候吃最好 少许纤维灶是什么意思
尿液分析是检查什么bjcbxg.com 鲨鱼怕什么hcv9jop4ns1r.cn 脑梗什么原因导致的hcv9jop1ns3r.cn 眼睛有眼屎是什么原因hcv7jop7ns4r.cn 放线菌是什么hcv8jop2ns7r.cn
突如其来什么意思wzqsfys.com 单纯疱疹吃什么药hcv9jop3ns3r.cn 咸鱼翻身是什么意思hcv8jop3ns8r.cn 凭什么姐hcv9jop3ns8r.cn 类风湿和风湿有什么区别hcv9jop3ns3r.cn
待见是什么意思aiwuzhiyu.com 咳嗽属于什么科室hcv8jop8ns7r.cn 进国企需要什么条件hcv8jop8ns4r.cn 青出于蓝是什么意思hcv8jop6ns1r.cn 三五成群十双在是什么生肖hcv8jop3ns1r.cn
脸基尼是什么意思hcv7jop9ns2r.cn 痰湿体质吃什么食物好hcv8jop8ns5r.cn 白细胞阳性什么意思hcv7jop9ns6r.cn 甜五行属什么hcv7jop6ns6r.cn 背上长毛是什么原因引起的hcv8jop7ns4r.cn
百度