Skip to content

Instantly share code, notes, and snippets.

@kyleferguson
Last active December 19, 2023 06:10
Show Gist options
  • Star 26 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kyleferguson/52d0c44bfec2914f8f934454f438c4de to your computer and use it in GitHub Desktop.
Save kyleferguson/52d0c44bfec2914f8f934454f438c4de to your computer and use it in GitHub Desktop.
Example Laravel deployment for Kubernetes
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: platform-api
spec:
replicas: 3
selector:
matchLabels:
app: platform-api
template:
metadata:
labels:
app: platform-api
commit: [INSERTED_DURING_CI]
spec:
containers:
- name: app
image: us.gcr.io/nexmillio/platform-api:latest
imagePullPolicy: Always
ports:
- {containerPort: 80}
env:
- { name: "APP_ENV", value: "production" }
- { name: "APP_DEBUG", value: "false" }
- { name: "APP_KEY", valueFrom: { secretKeyRef: { name: platform-api-secrets, key: app.key }} }
- { name: "APP_TIMEZONE", value: "UTC" }
- { name: "HASH_ID_SECRET", valueFrom: { secretKeyRef: { name: platform-api-secrets, key: hash.id.secret }} }
livenessProbe:
httpGet:
path: /healthz
port: 80
initialDelaySeconds: 10
timeoutSeconds: 3
FROM php:7.1-apache
ADD . /var/www
ADD ./site.conf /etc/apache2/sites-enabled/000-default.conf
RUN apt-get update && apt-get install -y libmcrypt-dev mysql-client && \
docker-php-ext-install mcrypt pdo_mysql opcache && \
pecl install redis-3.1.2 && docker-php-ext-enable redis && \
a2enmod rewrite
WORKDIR /var/www
apiVersion: v1
kind: Secret
metadata:
name: platform-api-secrets
data:
app.key: [BASE64_VALUE]
hash.id.secret: [BASE64_VALUE]
db.password: [BASE64_VALUE]
apiVersion: v1
kind: Service
metadata:
name: platform-api
spec:
selector:
app: platform-api
ports:
- protocol: TCP
port: 80
type: NodePort
@DawTaylor
Copy link

Could you share your site.conf file?

@EamonKeane
Copy link

EamonKeane commented Oct 29, 2017

Nice work. Would be good to have a reference laravel project in Helm (https://kubeapps.com/) if you find the time!

Edit - so I found the time to put it together myself, see here for an end to end example:
https://github.com/EamonKeane/laravel5-5-example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment