-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(irsa): add irsa configuration, add service account to give pods …
…access to db secret
- Loading branch information
1 parent
0c6c811
commit 55376d3
Showing
7 changed files
with
311 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as ecrAssets from '@aws-cdk/aws-ecr-assets'; | ||
import * as eks from '@aws-cdk/aws-eks'; | ||
import * as cdk from '@aws-cdk/core'; | ||
|
||
interface MigrateJobProps { | ||
env: {[key: string]: string}[]; | ||
cluster: eks.ICluster; | ||
backendImage: ecrAssets.DockerImageAsset; | ||
namespace: string; | ||
} | ||
|
||
export class MigrateJob extends cdk.Construct { | ||
public manifest: any; | ||
constructor(scope: cdk.Construct, id: string, props: MigrateJobProps) { | ||
super(scope, id); | ||
|
||
const migrateJobManifest: any = { | ||
apiVersion: 'batch/v1', | ||
kind: 'Job', | ||
metadata: { | ||
namespace: props.namespace, | ||
name: 'django-migrate', | ||
}, | ||
spec: { | ||
template: { | ||
spec: { | ||
serviceAccountName: 'pod-service-account', | ||
containers: [ | ||
{ | ||
name: 'migrate', | ||
image: props.backendImage.imageUri, | ||
env: props.env, | ||
args: ['python3', 'manage.py', 'migrate'], | ||
}, | ||
], | ||
restartPolicy: 'Never', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
this.manifest = migrateJobManifest; | ||
|
||
// props.cluster.addManifest('migrate-job', migrateJobManifest); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import * as ecrAssets from '@aws-cdk/aws-ecr-assets'; | ||
import * as eks from '@aws-cdk/aws-eks'; | ||
import * as cdk from '@aws-cdk/core'; | ||
|
||
interface WebResourcesProps { | ||
env: {[key: string]: string}[]; | ||
cluster: eks.ICluster; | ||
backendImage: ecrAssets.DockerImageAsset; | ||
namespace: string; | ||
webCommand: string[]; | ||
} | ||
|
||
/** | ||
* This construct provides the Kubernetes manifests for the Django web application | ||
* | ||
* It includes a service and a deployment manifest that share some common names and labels | ||
* | ||
* The service is references by the Ingress object called `app-ingress` | ||
* | ||
*/ | ||
export class WebResources extends cdk.Construct { | ||
|
||
public serviceManifest: any; | ||
public deploymentManifest: any; | ||
|
||
constructor(scope: cdk.Construct, id: string, props: WebResourcesProps) { | ||
super(scope, id); | ||
|
||
const name = 'api-http'; | ||
const selector = { app: name }; | ||
|
||
const webDeploymentManifest: any = { | ||
apiVersion: 'apps/v1', | ||
kind: 'Deployment', | ||
metadata: { | ||
namespace: props.namespace, | ||
name, | ||
}, | ||
spec: { | ||
replicas: 1, | ||
selector: { | ||
matchLabels: selector, | ||
}, | ||
template: { | ||
metadata: { | ||
labels: selector, | ||
}, | ||
spec: { | ||
containers: [ | ||
{ | ||
name, | ||
image: props.backendImage.imageUri, | ||
env: props.env, | ||
args: props.webCommand, | ||
ports: [ | ||
{ | ||
containerPort: 8000, | ||
name: 'http', | ||
}, | ||
], | ||
}, | ||
], | ||
restartPolicy: 'Always', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
const webServiceManifest: any = { | ||
apiVersion: 'v1', | ||
kind: 'Service', | ||
metadata: { | ||
labels: selector, | ||
name, | ||
namespace: props.namespace, | ||
}, | ||
spec: { | ||
selector, | ||
ports: [ | ||
{ | ||
port: 80, | ||
targetPort: 8000, | ||
protocol: 'TCP', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
this.deploymentManifest = webDeploymentManifest; | ||
this.serviceManifest = webServiceManifest; | ||
} | ||
} |
Oops, something went wrong.