Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cloud-computing-msc-ai-examples
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Rieger
cloud-computing-msc-ai-examples
Commits
605eb739
Commit
605eb739
authored
4 years ago
by
Sebastian Rieger
Browse files
Options
Downloads
Patches
Plain Diff
Add 'kubernetes-example/kubectl-intro.md'
parent
a2942f3d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
kubernetes-example/kubectl-intro.md
+115
-0
115 additions, 0 deletions
kubernetes-example/kubectl-intro.md
with
115 additions
and
0 deletions
kubernetes-example/kubectl-intro.md
0 → 100644
+
115
−
0
View file @
605eb739
# Introduction to kubectl
## Deployment of the needed description in kubernetes
These are two approaches to create the description in Kuberentes:
```
bash
# create a namespace
kubectl create namespace web-test
# Then choose one of the following ways:
# (1) Create the description
kubectl create
-f
nginx.yml
-f
service.yml
# (2) Create or update descriptions if existing
kubectl apply
-f
nginx.yml
-f
service.yml
```
## To show it is working
Here are some useful commands:
```
bash
# show nodes
kubectl get nodes
# show pods for our namespace
kubectl get
-n
web-test pods
# show deployments for our namespace
kubectl get
-n
web-test deployment
# show services for our namespace
kubectl get
-n
web-test service
# show logs of deployed nginx instances
kubectl logs
-n
web-test deployment/nginx-deployment
```
## Scaling up and down
```
bash
# scale up instances to 5
kubectl scale deployment/nginx-deployment
--replicas
=
5
# scale down instances again to 3
kubectl scale deployment/nginx-deployment
--replicas
=
3
```
## To see it is working in the browser ;)
The nginx instances are reachable at the floating ips of the
**node**
-instances at port
**30007**
in our case.
## Many other things can be done ;)
-
Autoscaling
-
Detailled Service functions (LoadBalancer, ...)
-
Dashboard
-
FaaS Setup ;)
-
...
## Appendix
### Nginx description
*nginx.yml:*
```
yml
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
name
:
nginx-deployment
namespace
:
web-test
spec
:
selector
:
matchLabels
:
app
:
nginx-deployment
replicas
:
3
# tells deployment to run 3 pods matching the template
template
:
metadata
:
labels
:
app
:
nginx-deployment
spec
:
containers
:
-
name
:
nginx
image
:
nginx:latest
ports
:
-
containerPort
:
80
```
### Nginx service description
*service.yml:*
```
yml
apiVersion
:
v1
kind
:
Service
metadata
:
name
:
nginx-service
namespace
:
web-test
spec
:
type
:
NodePort
selector
:
app
:
nginx-deployment
ports
:
# By default and for convenience, the `targetPort` is set to the same value as the `port` field.
-
port
:
80
targetPort
:
80
# Optional field
# By default and for convenience, the Kubernetes control plane will allocate a port from a range (default: 30000-32767)
nodePort
:
30007
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment