Team Neptune needs 3 Pods of image httpd:2.4-alpine
, create a Deployment named neptune-10ab
for this. The containers should be named neptune-pod-10ab
. Each container should have a memory request of 20Mi
and a memory limit of 50Mi
.
Team Neptune has its own ServiceAccount neptune-sa-v2
under which the Pods should run. The Deployment should be in Namespace neptune
.
k -n neptune create deployment -h # help
k -n neptune create deploy -h # deploy is short for deployment
# check the export on the very top of this document so we can use $do
k -n neptune create deploy neptune-10ab --image=httpd:2.4-alpine $do > 4.yaml
vim 4.yaml
NOTE: Before 1.18 it used to be possible to use the kubectl run to create a deployment with any attributes, but not any longer.
Now make the required changes using vim:
# 4.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: neptune-10ab
name: neptune-10ab
namespace: neptune
spec:
replicas: 3 # change
selector:
matchLabels:
app: neptune-10ab
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: neptune-10ab
spec:
serviceAccountName: neptune-sa-v2 # add
containers:
- image: httpd:2.4-alpine
name: neptune-pod-10ab # change
resources: # add
limits: # add
memory: 50Mi # add
requests: # add
memory: 20Mi # add
status: {}
If we don't want to write the resources section manually we could run the following command and copy it manually into our yaml file:
k run tmp --image=busybox $do --requests=memory=20Mi --limits=memory=50Mi
k create -f 4.yaml # namespace already set in yaml
➜ k -n neptune get pod | grep neptune-10ab
neptune-10ab-7d4b8d45b-4nzj5 1/1 Running 0 57s
neptune-10ab-7d4b8d45b-lzwrf 1/1 Running 0 17s
neptune-10ab-7d4b8d45b-z5hcc 1/1 Running 0 17s