Skip to content

Creating and Deploy Deployment and Service Configs

clydeu edited this page Oct 6, 2018 · 2 revisions
  1. Create deployment and service config.
  2. Apply deployment kubectl create -f .\<deployment>.yml.
  3. Apply service kubectl create -f .\<service>.yml.
  4. Update deployment or service using kubectl apply -f <file>.yml.
  • Monitoring commands:
    • kubectl get deployments - list all deployments
    • kubectl get svc - list all services
    • kubectl get pods - list all pods
    • kubectl describe <pod> - get pod details

Use the --all-namespaces flag to list everything.

  • Deleting commands:
    • kubectl delete deployment <deployment name>
    • kubectl delete svc <service name>

Asp.Net Core Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
  labels:
    app: myapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: myapp
        image: <docker repository>/<image>:<tag>
        ports:
        - containerPort: 80
        env:
        - name: "ASPNETCORE_ENVIRONMENT"
          value: "Test"
      imagePullSecrets:
        - name: regcred

Asp.Net Core Service

kind: Service
apiVersion: v1
metadata:
  name: myapp
  labels:
    app: myapp
spec:
  selector:
    app: myapp
  ports:
  - protocol: TCP
    # Port accessible inside cluster
    port: 8081
    # Port to forward to inside the pod
    targetPort: 80
    # Port accessible outside cluster
    nodePort: 30001
  type: LoadBalancer

Clone this wiki locally