当前位置:网站首页>[cloud native learning notes] deploy applications through yaml files
[cloud native learning notes] deploy applications through yaml files
2022-06-24 21:18:00 【The night owl of the second dimension】
List of articles
Preface
The front part About k8s Of yaml The configuration file , This article will try to write yaml File deployment application .
One 、 Environmental preparation
except k8s Environmental Science , You also need to prepare the application image to be deployed . have access to docker Make it , If docker The warehouse can be pulled directly , It can also be configured to pull automatically . Here, choose the official website tutorial used in the last practice to use the image jocatalin/kubernetes-bootcamp.
Pull the image locally :docker pull jocatalin/kubernetes-bootcamp:v1
View local image :docker images
Two 、 Practice process
1. start-up k8s
Still use minikube:minikube start
2. Check the basic status of the cluster
Mainly node、pod、svc、deploy etc.
kubectl get node
kubectl get pod
kubectl get svc
kubectl get deploy
3. To write yaml Content
Use here deployment+service Deploy the application .
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: bootcamp-deploy
labels:
app: my-bootcamp
spec:
selector:
matchLabels:
app: my-bootcamp
replicas: 2
template:
metadata:
labels:
app: my-bootcamp
spec:
containers:
- name: test-bootcamp
image: jocatalin/kubernetes-bootcamp:v1
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: hello-bootcamp
spec:
type: NodePort
selector:
app: my-bootcamp
ports:
- protocol: TCP
port: 80
targetPort: 8080
nodePort: 30008
4. View deployment results
All States are running It means there's no problem . The conditions of this machine are as follows :
E:\k8sTest>kubectl get deploy
NAME READY UP-TO-DATE AVAILABLE AGE
bootcamp-deploy 2/2 2 2 64s
E:\k8sTest>kubectl get pod
NAME READY STATUS RESTARTS AGE
bootcamp-deploy-6b9599f456-h6ljq 1/1 Running 0 2m8s
bootcamp-deploy-6b9599f456-w9j7q 1/1 Running 0 2m8s
E:\k8sTest>kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-bootcamp NodePort 10.107.175.226 <none> 80:30008/TCP 2m10s
5. Initiate a request for interface testing
Due to the port security policy of the local environment , The high port is not enabled , Here we continue to use the method introduced before , Use k8s Built in cluster url Route forwarding to access the application :
First, open the internal agent portal of the cluster :kubectl proxy
adopt pod-name To access the application :
E:\k8sTest>curl http://localhost:8001/api/v1/namespaces/default/pods/bootcamp-deploy-6b9599f456-w9j7q/proxy/
Hello Kubernetes bootcamp! | Running on: bootcamp-deploy-6b9599f456-w9j7q | v=1
E:\k8sTest>curl http://localhost:8001/api/v1/namespaces/default/pods/bootcamp-deploy-6b9599f456-h6ljq/proxy/
Hello Kubernetes bootcamp! | Running on: bootcamp-deploy-6b9599f456-h6ljq | v=1
边栏推荐
- Nifi quick installation (stand-alone / cluster)
- Create a multithreaded thread class
- B站带货当学新东方
- 科创人·味多美CIO胡博:数字化是不流血的革命,正确答案藏在业务的田间地头
- JMeter basic learning records
- What are the problems with traditional IO? Why is zero copy introduced?
- Selenium crawl notes
- Format method and parse method of dateformat class
- Static routing job
- Pod lifecycle in kubernetes
猜你喜欢

Alibaba cloud schedules tasks and automatically releases them

传统的IO存在什么问题?为什么引入零拷贝的?

B站带货当学新东方

Concepts of kubernetes components

Background operation retry gave up; KeeperErrorCode = ConnectionLoss

微信小程序中使用vant组件

Nifi fast authentication configuration

Address mapping of virtual memory paging mechanism

Network security review office starts network security review on HowNet

maptalks:数据归一化处理与分层设色图层加载
随机推荐
Learn together and make progress together. Welcome to exchange
大厂出海,败于“姿态”
Handling of garbled JMeter response data - three solutions
yeb_ Back first day
Codeforces Round #720 (Div. 2)
database/sql
After idea installs these plug-ins, the code can be written to heaven. My little sister also has to arrange it
Leetcode (455) - distribute cookies
Analysis of errors in JSON conversion using objectmapper
Golang reflection operation collation
A/B测试助力游戏业务增长
Appium desktop introduction
More than ten years' work experience is recommended at the bottom of the box: how much does it cost to find a job? See here! Brothers and sisters are recommended to collect and pay attention
Adding subscribers to a list using mailchimp's API V3
Power apps Guide
A/b test helps the growth of game business
Learn to use a new technology quickly
Markdown use
How to enhance influence
Alibaba cloud schedules tasks and automatically releases them