Kubernetes: Difference between revisions
From wiki.vacula.xyz
No edit summary |
No edit summary |
||
| Line 5: | Line 5: | ||
* don't store configuration within the application | * don't store configuration within the application | ||
== Usage | == Usage == | ||
<nowiki> | <nowiki> | ||
# Create a deployment of 3 nginx services called "salesweb" | # Create a deployment of 3 nginx services called "salesweb" | ||
Latest revision as of 20:44, 1 May 2025
Concepts
Decoupling:
- run resources anywhere
- don't tie an application to a specific server
- don't store configuration within the application
Usage
# Create a deployment of 3 nginx services called "salesweb" kubectl create deployment salesweb --image=nginx:latest --replicas=3 # Create a service for the salesweb deployment to use port 80 inside the containers kubectl expose deployment salesweb --port=80 # Tell the ingress controller to redirect any traffic (including sub-paths) on "sales.example.com" to the salesweb service kubectl create ingress salesweb --rule="sales.example.com/*=salesweb:80"
Tips and Tricks
Don't write YAML files directly, generate them. Use kubectl create with the options --dry-run=client -o yaml to generate the YAML files. Alternatively, use a kubectl get command with -o yaml. Use kubectl apply -f to create or update resources from a YAML file.