Hi My name is Abdi-Rahman Daud. I am a software engineer and... In this blog I will be sharing whatever I find useful in the technology sector

 

This blog is running on Azure managed container service AKS using the dotnet based mini blog template. 

 

I followed a couple of other blogs and github issues to make this work. So let me share the docker file:

FROM microsoft/dotnet:latest
COPY . /app
WORKDIR /app
RUN ["dotnet", "restore"]
RUN ["dotnet", "build", "-c", "release"]
EXPOSE 80/tcp
ENTRYPOINT ["dotnet", "run", "--server.urls", "http://*:80"]

 

and the yaml file is as follows

 apiVersion: v1

kind: PersistentVolumeClaim

metadata:

  name: myApp-pv-claim

  annotations:

    volume.beta.kubernetes.io/storage-class: default

spec:

  accessModes:

    - ReadWriteOnce

  resources:

    requests:

      storage: 1Gi

---

apiVersion: apps/v1beta2

kind: Deployment

metadata:

  name: myApp

spec:

  replicas: 1

  minReadySeconds: 10

  strategy:

    type: RollingUpdate

    rollingUpdate:

      maxUnavailable: 1

      maxSurge: 1

  template:

    metadata:

      labels:

        app: myApp

    spec:

      containers:

      - name: myApp

        image: my-register.azurecr.io/myApp:latest

        imagePullPolicy: Always

        volumeMounts:

        - name: myApp-pv-storage

          mountPath: /mnt/azure

        ports:

        - containerPort: 80

        imagePullSecrets:

          - name: secret-my-register

      volumes:

      - name: myApp-pv-storage

        persistentVolumeClaim:

          claimName: myApp-pv-claim

---

apiVersion: v1

kind: Service

metadata:

  name: myApp

spec:

  type: LoadBalancer

  ports:

  - port: 80

    targetPort: 80

  selector:

    app: myApp

Docker version is 18, and k8s is 1.8

After each merge to master, this is the hook I am using to deploy (the last two lines are not working as expected so I will manually delete the pod to apply the new image, I am sure there is a better way to do this)

docker build -t local-image:latest .
docker tag locale-image:latest my-image-at-azure-acr:latest
az acr login -n my-acr-at-azure
docker push my-image-at-azure-acr:latest
kubectl apply -f myblog.yaml --validate=false
kubectl get pods

Comments

Be the first to post a comment

Post a comment