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

Dockerchanges #207

Merged
merged 3 commits into from
Nov 30, 2018
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
82 changes: 1 addition & 81 deletions kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,87 +273,7 @@ spec:

### Custom Plugins

To enable custom plugins to Microgateway, perform the following steps

- Create a directory structure as given below and place your custom plugins
```
plugin
|
|-- plugins
|
|- response-uppercase
| |
| |- index.js
| |- package.json
|- request-headers
| | - index.js
| - package.json

```
- From the plugin folder, create the zip for entire plugins folder.
```
plugin> zip -r plugins.zip plugins/

```

- Create a Dockerfile and add place this in plugin folder:

```
FROM gcr.io/apigee-microgateway/edgemicro:latest
RUN apt-get install unzip
COPY plugins.zip /opt/apigee/
RUN chown apigee:apigee /opt/apigee/plugins.zip
RUN su - apigee -c "unzip /opt/apigee/plugins.zip -d /opt/apigee"
EXPOSE 8000
EXPOSE 8443
ENTRYPOINT ["entrypoint"]
```


- Create a new Microgateway image (with the plugins) and push to your docker repository
```
docker build -t edgemicroplugins .
docker tag edgemicroplugins docker.io/your-project/edgemicroplugins
docker push docker.io/your-project/edgemicroplugins
```
- Set the plugin sequence in the org-env configuration file
```
edgemicro:
...
plugins:
sequence:
- oauth
- response-uppercase

```

- Service Deployment Configuration

* Update edgemicro deployment with new image:
for ex:
```
kubectl apply -f <(edgemicroctl -org=myorg -env=test -key=0e3ecea28a64099410594406b30e54439af5265f88fb -sec=e3919250bee37c69cb2e5b41170b488e1c1dbc6 -conf=/Users/jdoe/.edgemicro/apigeesearch-test-config.yaml -img=docker.io/your-ptoject/edgemicroplugins:latest)
```

- Manual Sidecar Configuration
For manual sidecar, add img parameter to your deployment.
For ex:
```
kubectl apply -f <(edgemicroctl -org=myorg -env=test-key=0e3ecea28a64099410594406b30e54439af5265f8 -sec=e3919250bee37c69cb2e5b41170b488e1c1d -conf=/Users/jdoe/.edgemicro/apigeesearch-test-config.yaml -img=docker.io/your-project/edgemicroplugins:latest -svc=samples/helloworld/helloworld.yaml)
```

- Automatic Sidecar Configuration
Edit the installation install/kubernetes/edgemicro-sidecar-injector-configmap-release.yaml
. Change the containers image to new image.
```
containers:
- name: edge-microgateway
image: docker.io/your-project/edgemicropluging:latest
```
Apply changes to cluster
```
kubectl apply -f install/kubernetes/edgemicro-sidecar-injector-configmap-release.yaml
```
To enable custom plugins to Microgateway, please refer to the documentation [here](./docker/edgemicro/README.md).

### Scaling Deployment

Expand Down
22 changes: 18 additions & 4 deletions kubernetes/docker/edgemicro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,26 @@ Build a new container with the plugins
Here is an example:
```
FROM gcr.io/apigee-microgateway/edgemicro:latest
RUN apt-get install unzip
COPY plugins.zip /opt/apigee/
RUN chown apigee:apigee /opt/apigee/plugins.zip
RUN su - apigee -c "unzip /opt/apigee/plugins.zip -d /opt/apigee"
USER root
RUN apk update && \
apk upgrade && \
apk add zip && \
mkdir /opt/apigee/customplugins && \
chown apigee:apigee /opt/apigee/customplugins
COPY plugins.zip /opt/apigee/customplugins
RUN su - apigee -c "unzip /opt/apigee/customplugins/plugins.zip -d /opt/apigee/customplugins"
EXPOSE 8000
EXPOSE 8443
USER apigee
ENTRYPOINT ["entrypoint"]
```

Build the new docker image
```
docker build -t edgemicrocustomplugin .
```

Start the new image
```
docker run -P -p 8000:8000 -d --name edgemicrocustomplugin -e EDGEMICRO_PLUGIN_DIR=/opt/apigee/customplugins/plugins -e EDGEMICRO_ORG=$EDGEMICRO_ORG -e EDGEMICRO_ENV=$EDGEMICRO_ENV -e EDGEMICRO_KEY=$EDGEMICRO_KEY -e EDGEMICRO_SECRET=$EDGEMICRO_SECRET -e EDGEMICRO_CONFIG=$EDGEMICRO_CONFIG -e SERVICE_NAME=edgemicrocustomplugin edgemicrocustomplugin
```
11 changes: 8 additions & 3 deletions kubernetes/docker/edgemicro/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh

APIGEE_ROOT="/opt/apigee"
EDGEMICRO_PLUGIN_DIRECTORY="/opt/apigee/plugins"
# Log File on Server.
LOG_FILE=${APIGEE_ROOT}/logs/edgemicro.log
echo "Log Location: [ $LOG_FILE ]"
Expand Down Expand Up @@ -44,20 +45,24 @@ start_edge_micro() {
sed -i.back "s/config_change_poll_interval.*/config_change_poll_interval: $EDGEMICRO_OVERRIDE_edgemicro_config_change_poll_interval/g" ${APIGEE_ROOT}/.edgemicro/$EDGEMICRO_ORG-$EDGEMICRO_ENV-config.yaml
fi

if [[ -n $EDGEMICRO_PLUGIN_DIR ]]
then
EDGEMICRO_PLUGIN_DIRECTORY=$EDGEMICRO_PLUGIN_DIR
fi

PROXY_NAME=edgemicro_$SERVICE_NAME
TARGET_PORT=$SERVICE_PORT
BASE_PATH=/
BACKGROUND=" &"
MGSTART=" edgemicro start -o $EDGEMICRO_ORG -e $EDGEMICRO_ENV -k $EDGEMICRO_KEY -s $EDGEMICRO_SECRET -r $EDGEMICRO_PORT -d ${APIGEE_ROOT}/plugins "
MGSTART=" edgemicro start -o $EDGEMICRO_ORG -e $EDGEMICRO_ENV -k $EDGEMICRO_KEY -s $EDGEMICRO_SECRET -r $EDGEMICRO_PORT -d $EDGEMICRO_PLUGIN_DIRECTORY"
LOCALPROXY=" export EDGEMICRO_LOCAL_PROXY=$EDGEMICRO_LOCAL_PROXY "
MGDIR="cd ${APIGEE_ROOT} "
DECORATOR=" export EDGEMICRO_DECORATOR=$EDGEMICRO_DECORATOR "
DEBUG=" export DEBUG=$DEBUG "


if [[ -n "$EDGEMICRO_PROCESSES" ]]
then
MGSTART=" edgemicro start -o $EDGEMICRO_ORG -e $EDGEMICRO_ENV -k $EDGEMICRO_KEY -s $EDGEMICRO_SECRET -p $EDGEMICRO_PROCESSES -d ${APIGEE_ROOT}/plugins "
MGSTART=" edgemicro start -o $EDGEMICRO_ORG -e $EDGEMICRO_ENV -k $EDGEMICRO_KEY -s $EDGEMICRO_SECRET -p $EDGEMICRO_PROCESSES -d $EDGEMICRO_PLUGIN_DIRECTORY"
fi

if [[ -n "$EDGEMICRO_LOCAL_PROXY" ]]
Expand Down