Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes Application with multiple Resources single YAML

currently i used docker-compose to arrange my application that consists of 3 dockerimages - a postgresql database and 2 wildfly application servers (Frontend-ui, backend).

My docker-compose.yml looks like this:

version: '3.0'
services:
  my-webgui-service:
    image: test/mywebgui
    ports:
    - "18081:8080"
    links:
    - my-app-service
  my-app-service:
    image: test/myapp
    ports:
    - "18080:8080"
    - "29990:9990"
    links:
    - db-service
  db-service:
    image: test/postgres
    ports:
    - "15432:5432

Now, i would like to implement the same thing via kubernetes.

Is it possible to arrange this in a single yaml-File, that contains the configuration for service, deployment and pods? I thought that it is easier to manage automated deployments when not having seperated yml-files.

Is this a best practise?

Best regards, Shane

like image 673
Shannon Avatar asked Sep 10 '18 10:09

Shannon


People also ask

How do I apply multiple YAML files in Kubernetes?

You can combine your yamls called a Multi-Resource yaml into one file using the --- operator. i.e. apiVersion: v1 kind: Service metadata: name: foo spec: ... --- apiVersion: v1 kind: Service metadata: name: bar spec: ...

Can multiple services run on same port Kubernetes?

Kubernetes will automatically allow you to use the same port number for multiple services. This is fantastic for developers. You don't need to remember that "this API uses port 8080, this other one uses 8082" and so on.

Can a deployment have multiple Replicasets?

The replica sets can be multiple up to a limit of 10 based on the number of updates that have been done using deployment. But only one replicaSet (the latest one) should be showing the number of pods; all other older sets should be showing 0 .


1 Answers

Yes it's possible, simply separate the different resources such as deployments, services, etc. with ---. Concerning if it's a good practice or not: a matter of taste, rather. If you have all in one file it's more self-contained but for kubectl apply -f it doesn't really matter since it operates on directories as well.

like image 89
Michael Hausenblas Avatar answered Oct 14 '22 07:10

Michael Hausenblas