While I’ve manually configured Kubernetes to create proof-of-concept sandbox systems, that is an inefficient approach for production systems. The kubectl create command can use a yaml file (or json, if you prefer that format). I maintain my manifests in a Git repository so changes can be tracked (and so I know where to find them!). Once you have a manifest, it’s a matter of using “kubectl create -f manifest1.yaml” or “kubectl create -f manifest1.yaml -f manifest2.yaml … -f manifestN.yaml” to bring the ‘stuff’ online.
But what goes into a manifest file? The following file would deploy four replicas of the sendmail container that is retained in my private registry.
If the namespaces have not been created,
apiVersion: v1 kind: Namespace metadata: name: sendmailtest
The command “kubectl get ns” will list namespaces on the cluster. Note that ‘deployment’ items were not available in the v1 API, so the v1beta1 version needs to be specified to configure a deployment.
--- apiVersion: v1 kind: Pod metadata: name: sendmail namespace: sendmailtest labels: app: sendmail spec: containers: - name: sendmail image: sendmail ports: - containerPort: 25 --- apiVersion: v1beta1 kind: Deployment metadata: name: sendmail spec: replicas: 4 template: metadata: labels: app: sendmail spec: containers: - name: sendmail image: 'rushworthdockerregistry/sendmail/sendmail/sendmail:latest' ports: - containerPort: 25 --- apiVersion: v1 kind: Service metadata: name: sendmail-service labels: name: sendmail-service spec: ports: - port: 25 targetPort: 25 protocol: TCP name: smtp selector: app: sendmail type: ClusterIP