- Learn OpenShift
- Denis Zuev Artemii Kropachev Aleksey Usov
- 259字
- 2021-08-13 16:03:53
Creating kubernetes services using YAML and JSON files
You can also create Kubernetes resources manually using YAML and JSON files. Let's go ahead and create a simple pod running a httpd web server using the kubectl create command. We will have to create a YAML-formatted file:
$ cat httpd-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: httpd
namespace: default
spec:
containers:
- name: httpd-container
image: httpd
ports:
- containerPort: 80
It may look a bit complicated and hard to understand, but as we move on in this book, you will see a lot of similarities between these YAML and JSON files.
Create a pod using the httpd-pod.yaml file:
$ kubectl create -f httpd-pod.yaml
$ kubectl get all
NAME READY STATUS RESTARTS AGE
po/httpd 1/1 Running 0 25s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
svc/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 56s
This command creates a pod named httpd; it does not create anything else. In larger deployments with heavy automation involved, this is the way to deploy Kubernetes resources, but this, of course, requires better Kubernetes skills.
Similarly, we can create other Kubernetes resources, including ReplicaSet, Deployment, and others.
- Kubernetes修煉手冊
- 操作系統實用教程(Linux版)
- Mobile-first Bootstrap
- Red Hat Enterprise Linux 8系統管理實戰
- 高性能Linux服務器構建實戰:系統安全、故障排查、自動化運維與集群架構
- Windows Server 2012網絡操作系統企業應用案例詳解
- 零基礎學鴻蒙PC:新一代國產操作系統
- Application Development in iOS 7
- Learn CUDA Programming
- Hadoop Operations and Cluster Management Cookbook
- 程序員必讀經典(算法基礎+計算機系統)
- Mastering AWS CloudFormation
- Apache ShardingSphere權威指南
- Selenium Framework Design in Data-Driven Testing
- 48小時精通SolidWorks 2014中文版鈑金設計技巧