Step 4 Deploy Kubernetes Resources By Imperative Configuration - truongnhatbui/techtrends GitHub Wiki
Kubernetes Resources
Now you have learned many Kubernetes recourses, in this exercise, you will deploy the following resources using the kubectl command.
-
a namespace
-
- name: default
-
- label: tier: test
-
a deployment:
-
- image: buinhattruong/techtrends:v1.0.0
-
- name: techtrends
-
- namespace: default
-
- replicas: 3
-
- labels: app: techtrends, tag: techtrends
-
a service:
-
- expose the above deployment on port 8111
-
- namespace: default
-
a configmap:
-
- name: techtrends
-
- containing key-value pair: version=techtrends
-
- namespace: default
Below is a snippet creating a namespace and labeling it, a deployment, a service, and a configmap using the kubectl operations.
# create the namespace
# note: label option is not available with `kubectl create`
kubectl create ns default
# label the namespace
kubectl label ns default tier=test
# create a techtrends Deployment in namespace `default`
kubectl create deploy techtrends --image=buinhattruong/techtrends:v1.0.0 -n default
# create the techtrends deployment
kubectl create deploy techtrends --image=buinhattruong/techtrends:v1.0.0 --replicas=3 --namespace default
# label the deployment
kubectl label deploy techtrends app=techtrends tag=techtrends --namespace default
# expose the nginx-alpine deployment, which will create a service
kubectl expose deployment techtrends --port=8111 --namespace default
# create a config map
kubectl create configmap techtrends --from-literal=version=techtrends --namespace default
Spoiler alert: in the next section, you will learn and practice how to deploy Kubernetes resources using a different approach.