Ingress Nginx SSH access and forwarding to Workspace container/pod

Yeah, did some more thinking and am now trying to “just” use docker image tagging for versions so I can use deployments more properly. Working on Laravel PHP FPM image in which I include the demo code now:

FROM php:7.4-fpm

WORKDIR /code

# https://learnk8s.io/blog/kubernetes-deploy-laravel-the-easy-way
# COPY . app to copy all laravel app files to this working directory
# Only use this option when this container is in a private repository
# Composer is added to https://github.com/smart48/smt-workspace 

RUN apt-get update && apt-get install -y libmcrypt-dev zip unzip git \
    libmagickwand-dev --no-install-recommends \
    && pecl install imagick \
    && docker-php-ext-enable imagick \
    && docker-php-ext-install pdo_mysql pcntl bcmath \
    && docker-php-ext-install opcache

# Configure non-root user.
ARG PUID=1000
ENV PUID ${PUID}
ARG PGID=1000
ENV PGID ${PGID}

RUN groupmod -o -g ${PGID} www-data && \
    usermod -o -u ${PUID} -g www-data www-data

COPY ./laravel.ini /usr/local/etc/php/conf.d
COPY ./opcache.ini /usr/local/etc/php/conf.d
COPY ./xlaravel.pool.conf /usr/local/etc/php-fpm.d/

COPY laravel /code

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN composer install \
&&  php artisan optimize \
&&  php artisan route:cache

This builds works well locally (outside of Minikube running Docker for Mac) and when I enter the container I can see the code added. I tagged the image and pushed it to Docker Hub:

docker tag smart48/smt-laravel smart48/smt-laravel:1.2

and it is on Docker Hub here.

and locally I see this on my Mac’s container:

docker run --name smt-laravel -d smart48/smt-laravel:1.2   
53e4d1fc52042b6923be79d4590f5babe29b82efcb2cf04cfba7b6e95dd4b062
➜  smt-laravel git:(master) ✗ docker exec -it smt-laravel bash 
root@53e4d1fc5204:/code# ll
bash: ll: command not found
root@53e4d1fc5204:/code# ls -la
total 916
drwxr-xr-x  1 root root   4096 Dec 28 08:20 .
drwxr-xr-x  1 root root   4096 Dec 28 08:24 ..
drwxr-xr-x  2 root root   4096 Dec 28 05:46 .circleci
-rw-r--r--  1 root root    171 Dec 28 05:46 .dockerignore
-rw-r--r--  1 root root    220 Dec 28 05:46 .editorconfig
-rw-r--r--  1 root root    777 Dec 28 05:46 .env.example
-rw-r--r--  1 root root    935 Dec 28 05:46 .env.smt.docker.example
...

However when I build Minikube with all the deployments the PHP deployment

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: php
  namespace: smt-local
  labels:
    tier: backend
spec:
  # autoscale using `kubectl autoscale deployment x --cpu-percent=50 --min=1 --max=10` instead of setting replicas
  # https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/
  # replicas: 2 
  selector:
    matchLabels:
      app: php
      tier: backend
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  minReadySeconds: 5
  template:
    metadata:
      labels:
        app: php
        tier: backend
    spec:
      containers:
        - name: php
          # image: php:7-fpm
          image: smart48/smt-laravel:1.2
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 9000
          resources:
            requests:
              cpu: 250m
            limits:
              cpu: 500m
          volumeMounts:
          - name: code-storage
          # may use /var/www/html at a later stage as this is php container base path 
          # and logical web root
            mountPath: /code
        # - name: laravel-horizon
        #   image: smart48/smt-horizon:latest
        #   # not sure if we need the port and volume here
        #   imagePullPolicy: IfNotPresent
        #   ports:
        #     - containerPort: 9377
        #   volumeMounts:
        #     - name: code-storage
        #       mountPath: /code
        #   command: ["/usr/local/bin/php", "artisan", "horizon"]
        #   lifecycle:
        #     preStop:
        #       exec:
        #         command: ["/usr/local/bin/php", "artisan", "horizon:terminate"]
      # Laravel Code Download so we can run Horizon without issues 
      # and have a codebase to start with For private repo better to add code to laravel image 
      # https://codepre.com/how-to-perform-git-clone-in-kubernetes-pod-deployment.html
      # commented out as we only need to fire it on first deployment
      # initContainers:
      #   - name: git-cloner
      #     image: alpine/git
      #     args:
      #         - clone
      #         - --single-branch
      #         - --
      #         - https://github.com/smart48/smt-demo
      #         - /data
      #     volumeMounts:
      #     - mountPath: /data
      #       name: code-storage
      volumes:
        - name: code-storage
          persistentVolumeClaim:
            claimName: code

is not loading with the code:

kubectl exec -it php-5bb756d65-rxp4h -- /bin/bash
root@php-5bb756d65-rxp4h:/code# ll
bash: ll: command not found
root@php-5bb756d65-rxp4h:/code# ls -la
total 8
drwxrwxrwx 2 root root 4096 Dec 28 07:41 .
drwxr-xr-x 1 root root 4096 Dec 28 08:23 ..

and

docker inspect --format='{{json .Config}}' d3cb7bf6eb60:

{"Hostname":"php-5bb756d65-v6482","Domainname":"","User":"0","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"ExposedPorts":{"9000/tcp":{}},"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PHP_PORT_9000_TCP_PROTO=tcp","KUBERNETES_SERVICE_PORT=443","NGINX_SERVICE_HOST=10.111.105.227","NGINX_PORT_80_TCP_PROTO=tcp","PHP_PORT_9000_TCP=tcp://10.100.113.2:9000","WORKSPACE_SERVICE_PORT_2222_TCP_PROTO=tcp","KUBERNETES_PORT_443_TCP_ADDR=10.96.0.1","PHP_PORT_9000_TCP_PORT=9000","NGINX_SERVICE_PORT=80","WORKSPACE_SERVICE_PORT_2222_TCP=tcp://10.102.125.50:2222","WORKSPACE_SERVICE_PORT=tcp://10.102.125.50:2222","KUBERNETES_SERVICE_PORT_HTTPS=443","PHP_SERVICE_HOST=10.100.113.2","PHP_SERVICE_PORT=9000","WORKSPACE_SERVICE_SERVICE_HOST=10.102.125.50","KUBERNETES_PORT=tcp://10.96.0.1:443","KUBERNETES_PORT_443_TCP=tcp://10.96.0.1:443","NGINX_PORT_80_TCP_ADDR=10.111.105.227","WORKSPACE_SERVICE_SERVICE_PORT=2222","KUBERNETES_PORT_443_TCP_PORT=443","WORKSPACE_SERVICE_PORT_2222_TCP_ADDR=10.102.125.50","PHP_PORT=tcp://10.100.113.2:9000","NGINX_PORT_80_TCP=tcp://10.111.105.227:80","NGINX_PORT_80_TCP_PORT=80","WORKSPACE_SERVICE_PORT_2222_TCP_PORT=2222","KUBERNETES_PORT_443_TCP_PROTO=tcp","PHP_PORT_9000_TCP_ADDR=10.100.113.2","NGINX_PORT=tcp://10.111.105.227:80","KUBERNETES_SERVICE_HOST=10.96.0.1","PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","PHPIZE_DEPS=autoconf \t\tdpkg-dev \t\tfile \t\tg++ \t\tgcc \t\tlibc-dev \t\tmake \t\tpkg-config \t\tre2c","PHP_INI_DIR=/usr/local/etc/php","PHP_EXTRA_CONFIGURE_ARGS=--enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --disable-cgi","PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64","PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64","PHP_LDFLAGS=-Wl,-O1 -pie","GPG_KEYS=42670A7FE4D0441C8E4632349E4FDC074A4EF02D 5A52880781F755608BF815FC910DEB46F53EA312","PHP_VERSION=7.4.13","PHP_URL=https://www.php.net/distributions/php-7.4.13.tar.xz","PHP_ASC_URL=https://www.php.net/distributions/php-7.4.13.tar.xz.asc","PHP_SHA256=aead303e3abac23106529560547baebbedba0bb2943b91d5aa08fff1f41680f4","PUID=1000","PGID=1000"],"Cmd":["php-fpm"],"Healthcheck":{"Test":["NONE"]},"Image":"smart48/smt-laravel@sha256:882fa1297a8680f1d2c6d600999aa5523f76b2b6b1f2ab512bf57fc3fda72f66","Volumes":null,"WorkingDir":"/code","Entrypoint":["docker-php-entrypoint"],"OnBuild":null,"Labels":{"annotation.io.kubernetes.container.hash":"22738de7","annotation.io.kubernetes.container.ports":"[{\"containerPort\":9000,\"protocol\":\"TCP\"}]","annotation.io.kubernetes.container.restartCount":"0","annotation.io.kubernetes.container.terminationMessagePath":"/dev/termination-log","annotation.io.kubernetes.container.terminationMessagePolicy":"File","annotation.io.kubernetes.pod.terminationGracePeriod":"30","io.kubernetes.container.logpath":"/var/log/pods/smt-local_php-5bb756d65-v6482_7529674a-7c8f-482d-9777-d9aa9f1f918f/php/0.log","io.kubernetes.container.name":"php","io.kubernetes.docker.type":"container","io.kubernetes.pod.name":"php-5bb756d65-v6482","io.kubernetes.pod.namespace":"smt-local","io.kubernetes.pod.uid":"7529674a-7c8f-482d-9777-d9aa9f1f918f","io.kubernetes.sandbox.id":"b5301fb5bc20692e3a93bf05574f780b95374731d96850bff9384162f0a2b5fb"},"StopSignal":"SIGQUIT"}

Any idea what I am missing?