In this tutorial, Move2Kube will add a custom Dockerfile, and a custom file.
workspace
and make it the current working directory. Assume all commands are executed within this directory.$ mkdir workspace && cd workspace
$ curl https://move2kube.konveyor.io/scripts/download.sh | bash -s -- -d samples/enterprise-app/src -r move2kube-demos
$ ls src
README.md config-utils customers docs frontend gateway orders
Dockerfile
is generated for the frontend
app, it uses registry.access.redhat.com/ubi8/nodejs-12
as the base image.start-nodejs.sh
in the frontend
service directory.myproject/deploy/yamls
directory.$ move2kube transform -s src/ --qa-skip && ls myproject/source/frontend && cat myproject/source/frontend/Dockerfile && ls myproject/deploy && rm -rf myproject
Dockerfile README.md dr-surge.js manifest.yml package-lock.json server.js stories test-setup.js webpack.common.js webpack.prod.js LICENSE __mocks__ jest.config.js nodemon.json package.json src stylePaths.js tsconfig.json webpack.dev.js
FROM registry.access.redhat.com/ubi8/nodejs-12
COPY . .
RUN npm install
RUN npm run build
EXPOSE 8080
CMD npm run start
cicd compose knative knative-parameterized yamls yamls-parameterized
The next steps will:
registry.access.redhat.com/ubi8/nodejs-12
to quay.io/konveyor/nodejs-12
.start-nodejs.sh
in the Node.js app directories along with the Dockerfile in the frontend
directory.myproject/deploy/yamls
to myproject/yamls-elsewhere
.customizations
sub-directory.$ curl https://move2kube.konveyor.io/scripts/download.sh | bash -s -- -d custom-dockerfile-change-built-in-behavior -r move2kube-transformers -o customizations
-c
flag.$ move2kube transform -s src/ -c customizations/ --qa-skip
Once the output is generated, note the following:
frontend
app contains the custom base image.start-nodejs.sh
was generated in the frontend
directory.myproject/yamls-elsewhere
directory and the parameterized YAMLs are also in myproject/yamls-elsewhere-parameterized
directory.$ ls myproject/source/frontend
Dockerfile README.md dr-surge.js manifest.yml package-lock.json server.js start-nodejs.sh stylePaths.js tsconfig.json webpack.dev.js LICENSE __mocks__ jest.config.js nodemon.json package.json src stories test-setup.js webpack.common.js webpack.prod.js
$ cat myproject/source/frontend/Dockerfile
FROM quay.io/konveyor/nodejs-12
COPY . .
RUN npm install
RUN npm run build
EXPOSE 8080
CMD sh start-nodejs.sh
$ ls myproject
Readme.md deploy scripts source yamls-elsewhere yamls-elsewhere-parameterized
The two customized transformers in the directory are nodejs
and kubernetes
.
The contents of custom-dockerfile-custom-files
are shown below:
$ tree customizations
customizations
└── custom-dockerfile-change-built-in-behavior
├── kubernetes
│ └── kubernetes.yaml
└── nodejs
├── nodejs.yaml
└── templates
├── Dockerfile
└── start-nodejs.sh
To custom configure a built-in transformer, copy the built-in transformer’s configuration directory from the move2kube
source, change the configurations, use it as a customization, and make it override the built-in transformer using the override
config in the yaml.
In this case, change the Dockerfile template, add a script, and change the transformer configuration YAML.
customizations/custom-dockerfile-change-built-in-behavior/nodejs/templates/Dockerfile
. The template is the same as the one used in the built-in transformer, except it is a custom base image and a custom CMD
.{% raw %}$ cat customizations/custom-dockerfile-change-built-in-behavior/nodejs/templates/Dockerfile
FROM quay.io/konveyor/nodejs-12
COPY . .
RUN npm install
{{- if .Build }}
RUN npm run build
{{- end}}
EXPOSE {{ .Port }}
CMD sh start-nodejs.sh{% endraw %}
customizations/custom-dockerfile-change-built-in-behavior/nodejs/templates/start-nodejs.sh
.$ ls customizations/custom-dockerfile-change-built-in-behavior/nodejs/templates/
Dockerfile start-nodejs.sh
transformer.yaml
is the transformer configuration with two changes compared to the built-in transformer:Nodejs-CustomFiles
(see name
field in the metadata
section).override
section which is asking Move2Kube to disable the transformer named Nodejs-Dockerfile
if it is present.$ cat customizations/custom-dockerfile-change-built-in-behavior/nodejs/nodejs.yaml
apiVersion: move2kube.konveyor.io/v1alpha1
kind: Transformer
metadata:
name: Nodejs-CustomFiles
labels:
move2kube.konveyor.io/task: containerization
move2kube.konveyor.io/built-in: true
spec:
class: "NodejsDockerfileGenerator"
directoryDetect:
levels: -1
consumes:
Service:
merge: false
produces:
Dockerfile:
disabled: false
DockerfileForService:
disabled: false
override:
matchLabels:
move2kube.konveyor.io/name: Nodejs-Dockerfile
config:
defaultNodejsVersion: "12"
kubernetes
transformer, change the name and override the config. Also change the default behavior of the transformer, which is to put the Kubernetes yamls in deploy/yamls
directory by changing the spec.config.outputPath
to yamls-elsewhere
.$ cat customizations/custom-dockerfile-change-built-in-behavior/kubernetes/kubernetes.yaml
{% raw %}apiVersion: move2kube.konveyor.io/v1alpha1
kind: Transformer
metadata:
name: KubernetesWithCustomOutputDirectory
labels:
move2kube.konveyor.io/built-in: true
spec:
class: "Kubernetes"
directoryDetect:
levels: 0
consumes:
IR:
merge: true
produces:
KubernetesYamls:
disabled: false
override:
matchLabels:
move2kube.konveyor.io/name: Kubernetes
dependency:
matchLabels:
move2kube.konveyor.io/kubernetesclusterselector: "true"
config:
outputPath: "yamls-elsewhere"
ingressName: "{{ .ProjectName }}"{% endraw %}
The next step is adding custom annotations to Kubernetes YAMLs.