Assuming I have two multi-container pods and services for exposing the pods to the cluster. I also have Replication controller for maintaining the number of pods at any time.
The above cluster is an trivial example. In this point I have two pod files, two service files and two RC files. This makes the file management difficult.
I know that all the files can be put in a directory and use kubectl create -f directory to execute whole thing in a single command. But, I feel the file management is a overhead. Is there something like docker-compose.yml, where we can include all pods in a single file.
I would like to know the best practices for using kubernetes in production. Changing many files in production does not seem to be an good idea.
Configuration files are typically stored in source control, such as Git. live object configuration / live configuration: The live configuration values of an object, as observed by the Kubernetes cluster. These are kept in the Kubernetes cluster storage, typically etcd.
The Kubernetes manifest is a JSON configuration file that describes the list of Kubernetes versions supported by HPE Ezmeral Runtime Enterprise, Kubernetes add-on versions, and specific container image version dependencies that are relevant during the installation of a Kubernetes cluster.
Containers within same pod share network namespace and IPC namespace but they have separate mount namespace and filesystem.
You can use triple dashes or List resource as in these examples:
examples:
List
apiVersion: v1
kind: List
items:
- apiVersion: v1
kind: Service
metadata:
name: list-service-test
spec:
ports:
- protocol: TCP
port: 80
selector:
app: list-deployment-test
- apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: list-deployment-test
labels:
app: list-deployment-test
spec:
replicas: 1
template:
metadata:
labels:
app: list-deployment-test
spec:
containers:
- name: nginx
image: nginx
Triple dash:
---
apiVersion: v1
kind: Pod
metadata:
labels:
name: redis
redis-sentinel: "true"
role: master
name: redis-master
spec:
containers:
- name: master
image: kubernetes/redis:v1
env:
- name: MASTER
value: "true"
ports:
- containerPort: 6379
resources:
limits:
cpu: "0.5"
volumeMounts:
- mountPath: /redis-master-data
name: data
- name: sentinel
image: kubernetes/redis:v1
env:
- name: SENTINEL
value: "true"
ports:
- containerPort: 26379
volumes:
- name: data
emptyDir: {}
---
apiVersion: v1
kind: Pod
metadata:
labels:
name: redis-proxy
role: proxy
name: redis-proxy
spec:
containers:
- name: proxy
image: kubernetes/redis-proxy:v1
ports:
- containerPort: 6379
name: api
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With