my problem is that I need to increase NATS max_payload in production environment but it uses Kubernetes and I have no idea how to do that, I tried to use ConfigMap but I had not success.
In local/dev environment it uses a NATS config file with docker so it works fine.
Way to make it works local: NATS with moleculer. How can I change NATS max_payload value?
Code inside k8s/deployment.develop.yaml
(...)
apiVersion: v1
kind: ServiceAccount
metadata:
name: nats
namespace: develop
labels:
account: nats
---
apiVersion: v1
kind: Service
metadata:
name: nats
namespace: develop
labels:
app: nats
service: nats
spec:
ports:
- port: 4222
targetPort: 4222
selector:
app: nats
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nats-v1
namespace: develop
labels:
app: nats
version: v1
spec:
replicas: 1
strategy: {}
selector:
matchLabels:
app: nats
version: v1
template:
metadata:
labels:
app: nats
version: v1
spec:
serviceAccountName: nats
containers:
- image: 'nats:alpine'
name: nats
ports:
- containerPort: 4222
restartPolicy: Always
tolerations: []
affinity: {}
Thanks!
The payload value is hardcoded into the docker image (in the nats-server.conf file), so you cannot change it via a configmap. The only solution I found is to build my own nats image with a modified nats-server.conf file.
Here is how to do it.
First, select an image flavor from the official repo and download the content (for example Dockerfile and nats-server.conf from here).
Modify the nats-server.conf file to change the max_payload value : just add the following line (this file is NOT in JSON format)
max_payload: 4Mb
Then build the image : docker image build .
Tag it, upload it to your own repo and use it instead of the official nats image
I would recommend using these NATS Helm charts and then use something like the following:
nats:
limits:
maxPayload: "5mb"
You can find a full example here: https://github.com/nats-io/k8s/tree/master/helm/charts/nats#limits
Related
I'm using a little bit of Javascript in my Blazor app to do some light work. Everything works fine on my local computer. When I publish to my Azure Static Web App, the Javascript does not execute. Here is the error message.
Refused to execute script from 'https://fullUrl/js.download' because its MIME type ('application/octet-stream') is not executable, and strict MIME type checking is enabled.
Here is my yaml file.
trigger:
- main
pool:
vmImage: ubuntu-latest
# vmImage: windows-latest
steps:
- checkout: self
submodules: true
- task: DotNetCoreCLI#2
inputs:
command: 'publish'
publishWebProjects: true
- task: AzureStaticWebApp#0
inputs:
app_location: '/'
api_location: ''
output_location: 'wwwroot'
azure_static_web_apps_api_token: $(deployment_token)
I placed this in my staticwebapp.config.json file.
"mimeTypes": {
".json": "text/json",
".js": "application/octet-stream"
}
Does anyone know how to get this to work? Thanks!
I finally got all of this to work. I renamed myfile.js.download to just myfile.js. I then changed another js file to js.js. Anyway, that seemed to be the change that was needed.
Here is the updated yaml file.
trigger:
- master
pool:
vmImage: ubuntu-latest
# vmImage: windows-latest
steps:
- task: DotNetCoreCLI#2
displayName: 'dotnet build'
inputs:
command: 'build'
arguments: '--configuration Release'
projects: 'YourProjectName.csproj'
- task: DotNetCoreCLI#2
displayName: 'dotnet publish'
inputs:
command: 'publish'
publishWebProjects: true
arguments: '--configuration Release'
zipAfterPublish: false
- task: AzureStaticWebApp#0
inputs:
skip_app_build: true
app_location: '/bin/Release/net5.0/publish/wwwroot'
output_location: ''
azure_static_web_apps_api_token: 'YOURDEPLOYMENTTOKEN'
My problem is that I need to increase max_payload value that NATS receive but I have no idea where I can do it.
The project is using Moleculer and NATS is created as a container with docker.
When I try to make a request which is bigger than 1MB NATS returns:
ERROR - NATS error. 'Maximum Payload Violation
Inside dockstation logs NATS returns:
cid:1 - maximum payload exceeded: 1341972 vs 1048576
I tried the following items:
Changing tranporter inside Moleculer Broker configs (https://moleculer.services/docs/0.12/transporters.html);
Add an config file for NATS to modify some options (https://hub.docker.com/_/nats);
Code example of Moleculer Broker configs:
const brokerConfig: BrokerOptions = {
...,
transporter: "NATS",
transit: {
maxQueueSize: 100000,
disableReconnect: false,
disableVersionCheck: false,
},
...
}
Code example of nats config file:
{
max_payload: 1000000
}
Error when I run docker with NATS config file:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/home/matheus/nats-server.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/08959b2fce0deb2abea27e103f7f4426b7ed6f3ef64b214f713ebb993c2373e6/merged\\\" at \\\"/var/lib/docker/overlay2/08959b2fce0deb2abea27e103f7f4426b7ed6f3ef64b214f713ebb993c2373e6/merged/nats-server.conf\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type. error Command failed with exit code 125.
You should create a configuration file for NATS. And push it to the container as a Docker volume and set the command as -c nats-server.conf
nats-server.conf
max_payload: 4Mb
Start container
docker run -d -p 4222:4222 -v ~/nats-server.conf:/nats-server.conf nats -c /nats-server.conf
I cannot resolve an issue that I was stuck with in my beginner tutorial. When I try to create just a deployment on Kubernetes from Jenkins, I got the error message.
According to my research, Jackson 2 API v2.10.0, Kubernetes v1.21.3, Kubernetes Client API v4.6.3-1, Kubernetes Continuous Deploy v2.1.2,
and I need to use Kubernetes Credentials v0.5.0 plug-ins. I don't know how can I do this?
How can I solve this problem? Could anyone pls help me?
Error
Starting Kubernetes deployment
Loading configuration: /var/lib/jenkins/workspace/k8sdeploy/k8sdeploy.yml
ERROR: ERROR: Can't construct a java object for tag:yaml.org,2002:io.kubernetes.client.openapi.models.V1Deployment; exception=Class not found: io.kubernetes.client.openapi.models.V1Deployment
in 'reader', line 1, column 1:
apiVersion: apps/v1
^
hudson.remoting.ProxyException: Can't construct a java object for tag:yaml.org,2002:io.kubernetes.client.openapi.models.V1Deployment; exception=Class not found: io.kubernetes.client.openapi.models.V1Deployment
in 'reader', line 1, column 1:
apiVersion: apps/v1
^
My Pipeline
pipeline {
agent any
stages {
stage('Clone App from Github') {
steps {
git credentialsId: 'github', url: 'https://github.com/eneslanpir/k8sdeploy'
}
}
stage("Wait For 5 Seconds"){
steps {
sleep 5
}
}
stage("Kubernetes Create Deployment"){
steps{
script {
kubernetesDeploy(configs: "k8sdeploy.yml", kubeconfigId: "kubeconfig")
}
}
}
}
}
My Deployment yaml from Github (Tested - Working on Kuberentes)
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment-jenkins
spec:
selector:
matchLabels:
app: nginx
replicas: 1
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx-jenkins
image: nginx:1.16.1
ports:
- containerPort: 80
When downgrade to Jackson 2 API v2.10.0, everythings are going wrong.
I solved the problem by trying the plugins in the links below.
https://updates.jenkins.io/download/plugins/
I've followed the Create a JAR with the scripts to deploy instruction to create a custom Javascript policy for checking user attributes and it seems to be deployed successfully, however, I can't see the policy name in the create policy dropdown. Is there any setting I need to enable for this feature?
After uploading the .jar file to /keycloak/standalone/deployments, it says WFLYSRV0010: Deployed "script.jar" (runtime-name : "script.jar") without any error. I can also see the {filename}.jar.deployed next to my script file.
Setup: I use docker-compose to launch a jboss/keycloak version 10.0.1 container. Here's my docker-compose file:
version: "3.1"
services:
keycloak:
image: jboss/keycloak
restart: always
ports:
- 8080:8080
environment:
KEYCLOAK_PASSWORD: admin
KEYCLOAK_USER: admin
volumes:
- ./deployments:/opt/jboss/keycloak/standalone/deployments
keycloak-scripts.json:
{
"policies": [
{
"name": "my-policy",
"fileName": "my-script-policy.js",
"description": "My Policy from a JS file"
}
]
}
my-script-policy.js:
var context = $evaluation.getContext();
var contextAttributes = context.getAttributes();
if (contextAttributes.containsValue('kc.client.network.ip_address', '127.0.0.1')) {
$evaluation.grant();
}
Client policy setting
Thank you in advance for any suggestions.
I'm struggling to use MyScript inside an Angular 6 project.
I already cloned the following repo from GitHub:
https://github.com/MyScript/web-integration-samples/tree/master/angular-integration-examples
Installed all the dependencies with npm install.
Changed this line of code:
import * as MyScriptJS from 'myscript/src/myscript';
for:
import * as MyScriptJS from 'myscript/dist/myscript.min.js';
Because there wasn't any file called myscript inside src folder.
Finally I edited this piece of code that registers a new editor:
this.editor = MyScriptJS.register(this.domEditor.nativeElement, {
recognitionParams: {
type: 'MATH',
protocol: 'WEBSOCKET',
apiVersion: 'V4',
server: {
scheme: 'https',
host: 'cloud.myscript.com',
applicationKey: 'xxx',
hmacKey: 'xxx',
},
},
});
And yes, I added both keys, took them from the Dashboard.
After this all I can see is a white canvas where I can draw but nothing happens, there is no other box to show any results.
This is a screen capture:
Thanks for any help!