Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Parsa Gachkar 2 posts 72 karma points
    Aug 23, 2021 @ 12:05
    Parsa Gachkar
    0

    Kubernetes Volume Setup Guide? Files get Corrupted on redployment!

    Hello Every One. this is My First question in this forum.

    I've been able to successfully deploy mssql2019 + volume for persistence also deploying Umbraco as Unattended on Kubernetes was a great success. I thought that it would help if I get two volumes and attach them to /wwwroot and /Views directories. Here is My manifest:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name:  parsa-gachkar-umb
      labels:
        app:  parsa-gachkar-umb
    spec:
      selector:
        matchLabels:
          app: parsa-gachkar-umb
      replicas: 1
      strategy:
        rollingUpdate:
          maxSurge: 25%
          maxUnavailable: 25%
        type: RollingUpdate
      template:
        metadata:
          labels:
            app:  parsa-gachkar-umb
        spec:
          containers:
          - name:  parsa-gachkar-umb
            image:  docker-registry-parsa-*****/personal-website:latest
            imagePullPolicy: Always
            resources:
              requests:
                cpu: 1
                ephemeral-storage: 2G
                memory: 2G
              limits:
                cpu: 1
                ephemeral-storage: 2G
                memory: 2G
          imagePullSecrets:
          - name: registrysecret       
            ports: 
            - containerPort:  80
              name:  tcp-80
            volumeMounts:
            - name: wwwroot
              mountPath: /app/wwwroot
            - name: views
              mountPath: /app/Views
          volumes:
          - name: wwwroot
            persistentVolumeClaim:
              claimName: parsa-gachkar-umb-wwwroot-pvc
          - name: views
            persistentVolumeClaim:
              claimName: parsa-gachkar-umb-views-pvc
          restartPolicy: Always
    

    Every thing works fine at this scenario🎉. But If I set replicas to 0 and back to 1

    For whom that don't know what this means Kubernetes will just simply stop the app, delete and everything except the volumes Redeploy the app and re-mount the volumes to the folders I specified before.

    Here is the issue: after redeploy Views and Media Files are Corrupted! I was wondering if anyone else managed to deploy Umbraco on Kubernetes and How did him/her Persist these folders. If any one knows how to solve this issue I'd appreciate his/her Help. Maybe I'm just dumb and missing something?

  • Parsa Gachkar 2 posts 72 karma points
    Aug 24, 2021 @ 20:22
    Parsa Gachkar
    0

    Ok looks like I was dumb 🤣. checked the folder from my pod's console looks like when volume attaches the disk is empty and there is no way to initialize volume with a preloaded data fixed the issue with a dirty .sh script hack 😁 cheers 🍻


    here my docker file and bash script btw:

    dockerfile:

    # syntax=docker/dockerfile:1
    FROM mcr.microsoft.com/dotnet/sdk AS build-env
    WORKDIR /app
    
    # Copy csproj and restore as distinct layers
    COPY *.csproj ./
    RUN curl https://api.nuget.org/v3/index.json -k
    RUN dotnet restore
    
    # Copy everything else and build
    COPY . .
    RUN dotnet publish -c Release -o out
    
    
    # Build runtime image
    FROM mcr.microsoft.com/dotnet/aspnet
    WORKDIR /app
    COPY --from=build-env /app/out .
    COPY --from=build-env /app/out /src
    COPY ./run.sh /src
    RUN chmod +x /src/run.sh
    ENTRYPOINT ["/src/run.sh"]
    

    run.sh:

    #!/bin/bash
    {
    dotnet PersonalWebsite.dll
    } || { 
    cp -R /src/. . && 
    dotnet PersonalWebsite.dll
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft