Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSCTTV-3854 Add OpenShift config for Rahti2 #237

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions aspnetcore/openshift/api/rahti2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Builder
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY aspnetcore/custom_nuget/ /app/custom_nuget
COPY aspnetcore/nuget.config ./
COPY aspnetcore/src/api/api.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY aspnetcore/src/api/ ./
RUN dotnet publish -c Release -o out



# Runtime image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY --from=build-env /app/out .
EXPOSE 8080
ENTRYPOINT ["dotnet", "api.dll"]
130 changes: 130 additions & 0 deletions aspnetcore/openshift/api/rahti2/template-api-devel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# This file is part of the research.fi service
#
# Copyright 2024 Ministry of Education and Culture, Finland
#
# :author: CSC - IT Center for Science Ltd., Espoo Finland [email protected]
# :license: MIT
apiVersion: template.openshift.io/v1
kind: Template
metadata:
labels:
app: mydata-api-devel
template: mydata-api-devel
name: mydata-api-devel
annotations:
description: "Mydata backend devel"
iconClass: icon-dotnet
objects:

# Service
- apiVersion: v1
kind: Service
metadata:
name: mydata-api-devel
labels:
app: mydata-api-devel
annotations:
description: Mydata backend devel
spec:
ports:
- name: dotnet
port: 8080
targetPort: 8080
selector:
app: mydata-api-devel

# Route
- apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: mydata-api-devel
labels:
app: mydata-api-devel
spec:
host: mydata-api-devel.2.rahtiapp.fi
to:
kind: Service
name: mydata-api-devel
weight: 100
port:
targetPort: dotnet
tls:
termination: edge
insecureEdgeTerminationPolicy: Redirect
wildcardPolicy: None

# ImageStream
- apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
name: mydata-api-devel
labels:
app: mydata-api-devel

# BuildConfig using Docker build strategy
- apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
name: mydata-api-build-devel
labels:
app: mydata-api-devel
spec:
source:
git:
uri: https://github.com/CSCfi/research-fi-mydata.git
ref: devel
contextDir: .
strategy:
type: Docker
dockerStrategy:
dockerfilePath: aspnetcore/openshift/api/rahti2/Dockerfile
output:
to:
kind: ImageStreamTag
name: mydata-api-devel:latest
successfulBuildsHistoryLimit: 2
failedBuildsHistoryLimit: 2

# Deployment
- apiVersion: apps/v1
kind: Deployment
metadata:
name: mydata-api-devel
labels:
app: mydata-api-devel
spec:
selector:
matchLabels:
app: mydata-api-devel
template:
metadata:
labels:
app: mydata-api-devel
spec:
containers:
- name: mydata-api-container-devel
image: image-registry.openshift-image-registry.svc:5000/researchfi-devel/mydata-api-devel:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
protocol: TCP
resources:
limits:
cpu: 500m
memory: 4Gi
requests:
cpu: 100m
memory: 1Gi
replicas: 1
triggers:
- type: ConfigChange
- type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- mydata-api-container-devel
from:
kind: ImageStreamTag
name: mydata-api-devel:latest
strategy:
type: RollingUpdate
130 changes: 130 additions & 0 deletions aspnetcore/openshift/api/rahti2/template-api-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# This file is part of the research.fi service
#
# Copyright 2024 Ministry of Education and Culture, Finland
#
# :author: CSC - IT Center for Science Ltd., Espoo Finland [email protected]
# :license: MIT
apiVersion: template.openshift.io/v1
kind: Template
metadata:
labels:
app: mydata-api-production
template: mydata-api-production
name: mydata-api-production
annotations:
description: "Mydata backend production"
iconClass: icon-dotnet
objects:

# Service
- apiVersion: v1
kind: Service
metadata:
name: mydata-api-production
labels:
app: mydata-api-production
annotations:
description: Mydata backend production
spec:
ports:
- name: dotnet
port: 8080
targetPort: 8080
selector:
app: mydata-api-production

# Route
- apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: mydata-api-production
labels:
app: mydata-api-production
spec:
host: mydata-api-production.2.rahtiapp.fi
to:
kind: Service
name: mydata-api-production
weight: 100
port:
targetPort: dotnet
tls:
termination: edge
insecureEdgeTerminationPolicy: Redirect
wildcardPolicy: None

# ImageStream
- apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
name: mydata-api-production
labels:
app: mydata-api-production

# BuildConfig using Docker build strategy
- apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
name: mydata-api-build-production
labels:
app: mydata-api-production
spec:
source:
git:
uri: https://github.com/CSCfi/research-fi-mydata.git
ref: master
contextDir: .
strategy:
type: Docker
dockerStrategy:
dockerfilePath: aspnetcore/openshift/api/rahti2/Dockerfile
output:
to:
kind: ImageStreamTag
name: mydata-api-production:latest
successfulBuildsHistoryLimit: 2
failedBuildsHistoryLimit: 2

# Deployment
- apiVersion: apps/v1
kind: Deployment
metadata:
name: mydata-api-production
labels:
app: mydata-api-production
spec:
selector:
matchLabels:
app: mydata-api-production
template:
metadata:
labels:
app: mydata-api-production
spec:
containers:
- name: mydata-api-container-production
image: image-registry.openshift-image-registry.svc:5000/researchfi-production/mydata-api-production:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
protocol: TCP
resources:
limits:
cpu: 1
memory: 8Gi
requests:
cpu: 500m
memory: 4Gi
replicas: 1
triggers:
- type: ConfigChange
- type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- mydata-api-container-production
from:
kind: ImageStreamTag
name: mydata-api-production:latest
strategy:
type: RollingUpdate
Loading
Loading