Skip to content
This repository has been archived by the owner on Nov 11, 2021. It is now read-only.

Commit

Permalink
Cron Job logging fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasK33 committed Dec 26, 2020
1 parent 870f969 commit e4bdebc
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 29 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ jobs:
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
Expand Down
23 changes: 14 additions & 9 deletions devops/kubernetes/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions devops/kubernetes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
},
"dependencies": {
"cdk8s": "^1.0.0-beta.5",
"constructs": "^3.2.76",
"constructs": "^3.2.80",
"dotenv": "^8.2.0",
"rename-cli": "^6.2.1"
},
"devDependencies": {
"@types/jest": "^26.0.19",
"@types/node": "^14.14.14",
"@types/node": "^14.14.16",
"cdk8s-cli": "^1.0.0-beta.5",
"jest": "^26.6.3",
"rimraf": "^3.0.2",
Expand Down
28 changes: 25 additions & 3 deletions devops/kubernetes/src/charts/fluentd/configs/kubernetes.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<match fluent.**>
<label @FLUENT_LOG>
@type null
</match>
</label>

<source>
@type tail
Expand Down Expand Up @@ -191,13 +191,35 @@
ca_file "#{ENV['KUBERNETES_CA_FILE']}"
</filter>

# Fixes json fields for Elasticsearch
# Parse docker JSON logs
<filter kubernetes.**>
@id filter_parser
@type parser
key_name log
reserve_data true
remove_key_name_field true

<parse>
@type multi_format
<pattern>
format json
</pattern>
<pattern>
format none
</pattern>
</parse>
</filter>

# Parse application JSON logs
<filter kubernetes.**>
@id filter_parser_second
@type parser
key_name log
reserve_data true
remove_key_name_field true

emit_invalid_record_to_error false

<parse>
@type multi_format
<pattern>
Expand Down
14 changes: 7 additions & 7 deletions devops/kubernetes/src/charts/fluentd/fluentd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export class FluentdConstruct extends Construct {
new KubeServiceAccount(this, "service-account", {
metadata: {
name: "fluentd",
namespace: "kube-system",
namespace: "logs",
},
});

new KubeClusterRole(this, "cluster-role", {
metadata: {
name: "fluentd",
namespace: "kube-system",
namespace: "logs",
},
rules: [
{
Expand All @@ -47,7 +47,7 @@ export class FluentdConstruct extends Construct {
{
kind: "ServiceAccount",
name: "fluentd",
namespace: "kube-system",
namespace: "logs",
},
],
});
Expand All @@ -58,7 +58,7 @@ export class FluentdConstruct extends Construct {
new KubeConfigMap(this, "configs", {
metadata: {
name: "fluentd-configs",
namespace: "kube-system",
namespace: "logs",
},
binaryData: readdirSync(directory).reduce<Record<string, string>>(
(acc, file) => {
Expand All @@ -75,7 +75,7 @@ export class FluentdConstruct extends Construct {
new KubeDaemonSet(this, "daemon-set", {
metadata: {
name: "fluentd",
namespace: "kube-system",
namespace: "logs",
labels: {
"k8s-app": "fluentd-logging",
version: "v1",
Expand Down Expand Up @@ -151,11 +151,11 @@ export class FluentdConstruct extends Construct {
],
resources: {
limits: {
memory: "200Mi",
memory: "400Mi",
},
requests: {
cpu: "100m",
memory: "200Mi",
memory: "400Mi",
},
},
volumeMounts: [
Expand Down
7 changes: 7 additions & 0 deletions devops/kubernetes/src/cronjob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ export class FortifyCronJob extends Construct {
value: JOBS_SENTRY_DSN,
});

if (!env.find((envvar) => envvar.name === "NODE_ENV")) {
env.push({
name: "NODE_ENV",
value: "production",
});
}

const image =
options.image ??
(REGISTRY ?? "") +
Expand Down
2 changes: 1 addition & 1 deletion services/jobs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/jobs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jobs",
"version": "1.4.0",
"version": "1.4.1",
"description": "Job scripts and one off scripts",
"author": {
"name": "Thomas Kosiewski"
Expand Down
2 changes: 1 addition & 1 deletion services/jobs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ yargs
const healthCheck = container.get(HealthCheck);
await healthCheck.start();

logger.info(argv);
logger.info("arguments", argv);

if (container.isBound(argv.script)) {
const fortifyScript = container.get<FortifyScript>(
Expand Down

0 comments on commit e4bdebc

Please sign in to comment.