Skip to content

Commit

Permalink
Merge pull request #595 from renuka-fernando/200-scenarios
Browse files Browse the repository at this point in the history
Add Scenarios Resources
  • Loading branch information
pubudu538 authored May 3, 2021
2 parents aaffa56 + 4ee90ce commit 049ff65
Show file tree
Hide file tree
Showing 12 changed files with 522 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ metadata:
spec:
swaggerConfigMapName: petstore-cm
paramsValues: params-cm
certsValues: certs-cm
certsValues: certs-cm
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,22 @@
apiVersion: wso2.com/v1alpha2
kind: TargetEndpoint
metadata:
name: products-privatejet
name: products
labels:
app: wso2
app: products-backend
spec:
applicationProtocol: http
ports:
- name: prod-ep
port: 80
targetPort: 9090
targetPort: 8080
deploy:
name: products-pj-service
dockerImage: pubudu/products:1.0.0
name: products
dockerImage: cakebakery/products:v1
minReplicas: 2
maxReplicas: 3
requestCPU: "60m"
reqMemory: "32Mi"
cpuLimit: "120m"
mode: privateJet
requestCPU: "2m"
reqMemory: "10Mi"
cpuLimit: "5m"
memoryLimit: "20Mi"
mode: privateJet
16 changes: 16 additions & 0 deletions api-operator/pkg/envoy/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,19 @@ const (
apiOperatorConfigHome = "API_OPERATOR_CONFIG_HOME"
apiOperatorDefaultConfigHome = "/usr/local/bin"
)

// constants related to API-CTL project
// TODO: use API-CTL code to init project
const (
apiYamlFile = "api.yaml"
swaggerDefinitionFile = "Definitions/swagger.yaml"
deploymentEnvFile = "deployment_environments.yaml"
// TODO: use API-CTL code to init project
deploymentEnvFileData = `type: deployment_environments
version: v4.0.0
data:
-
displayOnDevportal: true
deploymentEnvironment: Default
`
)
9 changes: 7 additions & 2 deletions api-operator/pkg/envoy/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,9 @@ func getSwaggerData(config *corev1.ConfigMap) (string, func(), error) {
}

swaggerDirectory, _ := ioutil.TempDir("", "api-swagger-dir*")
apiYamlPath := filepath.Join(swaggerDirectory, filepath.FromSlash("api.yaml"))
swaggerSavePath := filepath.Join(swaggerDirectory, filepath.FromSlash("Definitions/swagger.yaml"))
apiYamlPath := filepath.Join(swaggerDirectory, filepath.FromSlash(apiYamlFile))
swaggerSavePath := filepath.Join(swaggerDirectory, filepath.FromSlash(swaggerDefinitionFile))
deploymentEnvPath := filepath.Join(swaggerDirectory, filepath.FromSlash(deploymentEnvFile))
errCreateDirectory := createDirectories(swaggerDirectory)
if errCreateDirectory != nil {
return "", nil, errCreateDirectory
Expand All @@ -245,6 +246,10 @@ func getSwaggerData(config *corev1.ConfigMap) (string, func(), error) {
if err != nil {
return "", nil, err
}
err = ioutil.WriteFile(deploymentEnvPath, []byte(deploymentEnvFileData), os.ModePerm)
if err != nil {
return "", nil, err
}
swaggerZipFile, err, cleanupFunc := utils.CreateZipFileFromProject(swaggerDirectory, false)
if err != nil {
return "", nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,7 @@ spec:
requests:
cpu: 250m
memory: 250Mi
volumeMounts:
- mountPath: /home/wso2/security/
name: operator-vol
serviceAccountName: api-operator
volumes:
- name: operator-vol
secret:
items:
- key: tls.key
path: tls.key
- key: tls.crt
path: tls.crt
secretName: operator-secret
permissions:
- rules:
- apiGroups:
Expand Down Expand Up @@ -340,7 +328,7 @@ spec:
maintainers:
- email: announce@wso2.org
name: WSO2 product releases
maturity: 2.x-stable
maturity: stable
provider:
name: WSO2
version: 2.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

packageName: api-operator
channels:
- name: stable
- name: 1.x-stable
currentCSV: api-operator.v1.2.2
- name: 2.x-stable
currentCSV: api-operator.v2.0.0
Expand Down
22 changes: 22 additions & 0 deletions scenarios/scenario-1-target-endpoint/api_cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) 2021 WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
#
# WSO2 Inc. licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
# You may obtain a copy of the License at
#
# http:www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

apiVersion: wso2.com/v1alpha2
kind: API
metadata:
name: products-api
spec:
swaggerConfigMapName: products-cm
184 changes: 184 additions & 0 deletions scenarios/scenario-1-target-endpoint/swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
# Copyright (c) 2021 WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
#
# WSO2 Inc. licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
# You may obtain a copy of the License at
#
# http:www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

openapi: 3.0.0
servers:
- description: Localhost
url: http://localhost:8080
info:
description: This is a sample backend - products
version: v1
title: Products
contact:
email: renukapiyumal@gmail.com
tags:
- name: product
description: Products of store
x-wso2-production-endpoints:
urls:
- http://products
type: http
x-wso2-sandbox-endpoints:
urls:
- http://products
type: http
x-wso2-basePath: /products-api/v1
paths:
/products:
get:
tags:
- product
summary: All Products
description: All products of the store
responses:
200:
description: Successful operation
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Product"
post:
tags:
- product
summary: Add Product
description: Add new products to the store
requestBody:
content:
applicatoin/json:
schema:
$ref: "#/components/schemas/Product"

responses:
200:
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/Product"
400:
description: Invalid Product
/products/{id}:
get:
tags:
- product
summary: Find product by ID
description: Returns a single product
parameters:
- name: id
in: path
description: ID of product to return
required: true
schema:
type: integer
format: int64
example: 3
responses:
200:
description: successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/Product"
400:
description: Invalid ID supplied
404:
description: Product not found
put:
tags:
- product
summary: Update product by ID
description: Update a product
parameters:
- name: id
in: path
description: ID of product to update
required: true
schema:
type: integer
format: int64
example: 3
requestBody:
content:
applicatoin/json:
schema:
$ref: "#/components/schemas/Product"
responses:
200:
description: successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/Product"
400:
description: Invalid ID supplied
404:
description: Product not found
delete:
tags:
- product
summary: Delete product by ID
description: Delete a product
parameters:
- name: id
in: path
description: ID of product to delete
required: true
schema:
type: integer
format: int64
example: 3
responses:
200:
description: successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/Result"
400:
description: Invalid ID supplied
404:
description: Product not found
components:
schemas:
Product:
type: object
required:
- name
- category
- price
properties:
id:
type: integer
format: int64
example: 3
name:
type: string
example: ABC Smart TV
category:
type: string
example: Electronics
price:
type: integer
format: int64
example: 39999
Result:
type: object
properties:
result:
type: string
example: success
38 changes: 38 additions & 0 deletions scenarios/scenario-1-target-endpoint/targetendpoint_cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright (c) 2021 WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
#
# WSO2 Inc. licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
# You may obtain a copy of the License at
#
# http:www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

apiVersion: wso2.com/v1alpha2
kind: TargetEndpoint
metadata:
name: products
labels:
app: products-backend
spec:
applicationProtocol: http
ports:
- name: prod-ep
port: 80
targetPort: 8080
deploy:
name: products
dockerImage: cakebakery/products:v1
minReplicas: 2
maxReplicas: 3
requestCPU: "2m"
reqMemory: "10Mi"
cpuLimit: "5m"
memoryLimit: "20Mi"
mode: privateJet
24 changes: 24 additions & 0 deletions scenarios/scenario-2-endpoint-cert-override/api_cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2021 WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
#
# WSO2 Inc. licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
# You may obtain a copy of the License at
#
# http:www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

apiVersion: wso2.com/v1alpha2
kind: API
metadata:
name: cert-products
spec:
certsValues: cert-products-certs
paramsValues: cert-products-params
swaggerConfigMapName: cert-products-cm
Loading

0 comments on commit 049ff65

Please sign in to comment.