Skip to content

Commit f3ad8ce

Browse files
author
Prabha Kylasamiyer Sundara Rajan
committed
MTA-4610 Asset Generation CLI: First Commit
1 parent 00b6b5b commit f3ad8ce

5 files changed

+316
-0
lines changed

docs/cli-guide/master.adoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,18 @@ include::topics/mta-review-reports.adoc[leveloffset=+1]
101101
// Mavenize Your Application
102102
// include::topics/mavenize.adoc[leveloffset=+1]
103103

104+
//Generating platform Assets for application deployment
105+
include::topics/mta-cli-generate-assets.adoc[leveloffset=+1]
106+
107+
//Generating the discovery manifest
108+
include::topics/mta-cli-generate-discovery-manifest.adoc[leveloffset=+2]
109+
110+
//Generating the deployment manifest
111+
include::topics/mta-cli-generate-deployment-manifest.adoc[leveloffset=+2]
112+
113+
//Generate asset for a Java application
114+
include::topics/mta-cli-generate-deployment-asset-example.adoc[leveloffset=+2]
115+
104116
// Optimize {ProductShortName} Performance
105117
include::topics/mta-optimize-performance.adoc[leveloffset=+1]
106118

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
:_newdoc-version: 2.18.3
2+
:_template-generated: 2024-07-30
3+
:_mod-docs-content-type: CONCEPT
4+
5+
[id="mta-cli-generate-assets_{context}"]
6+
= Generating platform assets for application deployment
7+
8+
Starting from {ProductShortName} 7.3.0, you can run the `discover` and `generate` commands in the containerless {ProductShortName} {CLIName}. The commands automatically generate the manifests needed to deploy a Cloud Foundry (CF) application in the {ocp-short}.
9+
10+
* `Discover` command: Generates the discovery manifest in the YAML format from the CF application manifest. The discovery manifest preserves the specifications found in the CF manifest that define the metadata, runtime, and platform configurations.
11+
* `Generate` command: Generates the deployment manifest for {ocp} deployments by using the discovery manifest. The deployment manifest is generated by using a templating engine such as Helm that converts the discovery manifest into a Kubernetes-native format.
12+
13+
.Benefits of generating deployment assets by using the {ProductShortName} {CLIName}
14+
* Extending the {ProductShortName} {CLIName} to generate the Kubernetes and non-Kubernetes deployment manifests at once.
15+
* Generating deployment manifests using familiar template engines like Helm that are widely used for Kubernetes deployments.
16+
* Adhering to Kubernetes best practices when preparing the deployment manifest using Helm templates.
17+
18+
:FeatureName: Generating platform assets for application deployment
19+
include::developer-preview-feature.adoc[]
20+
21+
[id="support-matrix_{context}"]
22+
== Support matrix
23+
24+
* Source platform: Cloud Foundry (v3)
25+
* Target platform: {ocp-short}
26+
* CLI tool: {ProductShortName} {CLIName} 7.3.0
27+
* Status: Developer preview in 7.3.0
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * docs/cli-guide/master.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="mta-generate-deployment-asset-example_{context}"]
7+
= Generating the discovery and deployment manifest example
8+
9+
This example shows how to generate the discovery manifest and the deployment manifest of a Cloud Foundry (CF) Node.js application by using the `discover` and `generate` commands, respectively.
10+
11+
For this example, the following files and directories are used:
12+
13+
* CF Node.js application manifest name: `cf-nodejs-app.yaml`
14+
* Discovery manifest name: `discover.yaml`
15+
* Location of the application Helm chart: `helm_sample`
16+
* Deployment manifests: a ConfigMap and a Dockerfile
17+
* Output location of the deployment manifests: `newDir`
18+
19+
In this example, it is assumed that the `cf-nodejs-app.yaml` is located in the same directory as the {ProductShortName} {CLIName} binary. If the CF application manifest location is different, you can also enter the location path to the manifest as the `input`.
20+
21+
.Prerequisites
22+
* You installed {ProductShortName} {CLIName} 7.3.0.
23+
* You have a CF application manifest as a yaml file.
24+
* You created a Helm template to capture the required configurations for the {ocp} deployment.
25+
26+
.Procedure
27+
. Open the terminal application and navigate to the `<{ProductShortName}_HOME>/` directory.
28+
29+
. Verify the content of the CF Node.js application manifest:
30+
+
31+
[source,terminal]
32+
----
33+
$ cat cf-nodejs-app.yaml
34+
name: cf-nodejs
35+
lifecycle: cnb
36+
buildpacks:
37+
- docker://my-registry-a.corp/nodejs
38+
- docker://my-registry-b.corp/dynatrace
39+
memory: 512M
40+
instances: 1
41+
random-route: true
42+
----
43+
. To generate the discover manifest for the CF Node.js application:
44+
+
45+
[source,terminal]
46+
----
47+
$ ./{mta-cli} discover cloud-foundry \
48+
--input cf-nodejs-app.yaml \
49+
--output discover.yaml \
50+
----
51+
52+
. Verify the content of the discover manifest:
53+
+
54+
[source,terminal]
55+
----
56+
$ cat discover.yaml
57+
name: cf-nodejs
58+
randomRoute: true
59+
timeout: 60
60+
buildPacks:
61+
- docker://my-registry-a.corp/nodejs
62+
- docker://my-registry-b.corp/dynatrace
63+
instances: 1
64+
----
65+
66+
. To generate the deployment manifest in the `newDir` directory by using the `discover.yaml`:
67+
+
68+
[source,terminal]
69+
----
70+
$ ./{mta-cli} generate helm \
71+
--chart-dir helm_sample \
72+
--input discover.yaml --output-dir newDir
73+
----
74+
75+
. Check the contents of the Dockerfile the `newDir` directory:
76+
+
77+
[source,terminal]
78+
----
79+
$ cat ./newDir/Dockerfile
80+
FROM busybox:latest
81+
82+
RUN echo "Hello cf-nodejs!"
83+
----
84+
85+
. Check the contents of the ConfigMap in the `newDir` directory:
86+
+
87+
[source,terminal]
88+
----
89+
$ cat ./newDir/configmap.yaml
90+
apiVersion: v1
91+
kind: ConfigMap
92+
metadata:
93+
name: cf-nodejs-config
94+
data:
95+
RANDOM_ROUTE: true
96+
TIMEOUT: "60"
97+
BUILD_PACKS: |
98+
- docker://my-registry-a.corp/nodejs
99+
- docker://my-registry-b.corp/dynatrace
100+
INSTANCES: "1"
101+
----
102+
103+
. To override the `name` to `nodejs-app` and `INSTANCES` to `2` in the ConfigMap:
104+
+
105+
[source,terminal]
106+
----
107+
$ ./{mta-cli} generate helm \
108+
--chart-dir helm_sample \
109+
--input discover.yaml --set name="nodejs-app" \
110+
--set instances=2 \
111+
--output-dir newDir \
112+
----
113+
114+
. Check the contents of the ConfigMap again:
115+
+
116+
[source,terminal]
117+
----
118+
$ cat ./newDir/configmap.yaml
119+
apiVersion: v1
120+
kind: ConfigMap
121+
metadata:
122+
name: nodejs-app
123+
data:
124+
RANDOM_ROUTE: true
125+
TIMEOUT: "60"
126+
BUILD_PACKS: |
127+
- docker://my-registry-a.corp/nodejs
128+
- docker://my-registry-b.corp/dynatrace
129+
INSTANCES: "2"
130+
----
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * docs/cli-guide/master.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="mta-generate-deployment-manifest_{context}"]
7+
= Generating the deployment manifest
8+
Use the `generate` command to auto-generate the {ocp-full} deployment manifest for the Cloud Foundry (CF) application. Based on the Helm template that you provide, the command generates manifests such as a ConfigMap and non-Kubernetes manifests, such as a Dockerfile, for application deployment.
9+
10+
.Prerequisites
11+
* You generated a discovery manifest.
12+
* You created a Helm template to capture required configuration for the {ocp} deployment.
13+
14+
.Procedure
15+
. Open the terminal application and navigate to the `<{ProductShortName}_HOME>/` directory.
16+
. To generate the deployment manifest as an output file:
17+
+
18+
[source,terminal]
19+
----
20+
$ ./{mta-cli} generate helm --chart-dir helm_sample \
21+
--input <path_to_discovery-manifest> \
22+
--output-dir <location_of_deployment_manifest> \
23+
----
24+
. Verify the ConfigMap.
25+
+
26+
[source,terminal]
27+
----
28+
$ ./{mta-cli} cd <location_of_deployment_manifest> \
29+
$ cat configmap.yaml
30+
$ cat Dockerfile
31+
----
32+
. Verify the Dockerfile.
33+
+
34+
[source,terminal]
35+
----
36+
$ ./{mta-cli} cd <location_of_deployment_manifest> \
37+
$ cat Dockerfile
38+
----
39+
40+
[source,terminal,subs="attributes+"]
41+
----
42+
Usage:
43+
$ {mta-cli} generate [flags]
44+
----
45+
46+
[source,terminal,subs="attributes+"]
47+
----
48+
Usage:
49+
$ {mta-cli} generate helm [flags]
50+
----
51+
52+
.Commands and Flags for `generate`
53+
[width="100%",cols="30%,30%,40%",options="header"]
54+
|===
55+
|Commands | Flags| Description
56+
57+
a|`generate`
58+
a|`-h`, `--help`
59+
a|Help for generate.
60+
61+
.6+a|`generate helm`
62+
a|
63+
a|Generate the deployment manifest by using the Helm template.
64+
65+
a|`--chart-dir`
66+
a|Specify the directory that contains the Helm chart.
67+
68+
a|`--input`
69+
a|Specify the location of the < _discovery-manifest-name.yaml_ > to generate the deployment manifest.
70+
71+
a|`--non-k8s-only`
72+
a|Generate only non-Kubernetes templates such as a Dockerfile.
73+
74+
a|`--output-dir`
75+
a|Specify the location to which the deployment manifests are saved.
76+
77+
a|`--set`
78+
a|Overrides values of attributes in the discovery manifest with the key-value pair entered from the CLI.
79+
|===
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * docs/cli-guide/master.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="mta-generate-discovery-manifest_{context}"]
7+
= Generating the discovery manifest
8+
Use the `discover` command to generate the discovery manifest for the Cloud Foundry (CF) application. The discovery manifest preserves configurations such as application properties, resource allocations, environment variables, and service bindings found in the CF manifest.
9+
10+
.Prerequisites
11+
* You installed {ProductShortName} {CLIName} 7.3.0.
12+
* You have a CF application manifest as a yaml file.
13+
14+
.Procedure
15+
. Open the terminal application and navigate to the `<{ProductShortName}_HOME>/` directory.
16+
17+
. To list supported platforms for the discovery process:
18+
+
19+
[source,terminal]
20+
----
21+
$ ./{mta-cli} discover --list-platforms
22+
----
23+
24+
. To generate the discovery manifest for a CF application as an output file:
25+
+
26+
[source,terminal]
27+
----
28+
$ ./{mta-cli} discover cloud-foundry \
29+
--input <path_to_application-manifest> \
30+
--output <path_to_discovery-manifest>\
31+
----
32+
33+
[source,terminal,subs="attributes+"]
34+
----
35+
Usage:
36+
$ {mta-cli} discover [flags]
37+
----
38+
39+
[source,terminal,subs="attributes+"]
40+
----
41+
Usage:
42+
$ {mta-cli} discover cloud-foundry [flags]
43+
----
44+
45+
.Commands and Flags for `discover`
46+
[width="100%",cols="30%,30%,40%",options="header"]
47+
|===
48+
|Commands | Flags| Description
49+
50+
.2+a|`discover`
51+
a|`-h`, `--help`
52+
a|Help for discover.
53+
54+
55+
a|`--list-platforms`
56+
a|List supported platforms for the discovery process.
57+
58+
59+
.3+a|`discover cloud-foundry`
60+
a|
61+
a|Discover Cloud Foundry applications.
62+
63+
a|`--input`
64+
a|Specify the location of the < _app-manifest-name.yaml_ > to discover the application configurations.
65+
66+
a|`--output`
67+
a|Specify the location to save the < _discovery-manifest-name.yaml_ >.
68+
|===

0 commit comments

Comments
 (0)