Skip to content

Instantly share code, notes, and snippets.

View rinormaloku's full-sized avatar

Rinor Maloku rinormaloku

View GitHub Profile
@rinormaloku
rinormaloku / storing2keyvault.ps1
Last active January 14, 2018 10:03
[Storing acs-engine data to the KeyVault] Script to store acs engine data to the keyvault #acs-engine #keyvault
# Create KeyVault to store the secrets
$kv_name = 'kvnamecv1'
$keyvault_rg = 'keyvaultrg1'
$keyvault_rg_location = 'westeurope'
az group create --name $keyvault_rg --location $keyvault_rg_location
az keyvault create --name $kv_name --resource-group $keyvault_rg --enabled-for-template-deployment --enabled-for-deployment
###END
# Save Service Principal password
@rinormaloku
rinormaloku / update_parameters_with_ref2keyvault.ps1
Last active January 24, 2018 15:03
[Update azuredeploy.parameters.json with references from keyvault] Update keyvault to use references to keyvault secrets #keyvault #acs-engine
# Update for e.g. caCertificate from
"caCertificate": {
"value": "[CERTIFICATE THAT CAN BE SEEN]"
},
# to
"caCertificate": {
"reference": {
"keyVault": {
"id": "[KEY_VAULT_ID]"
},
@rinormaloku
rinormaloku / azuredeploy.parameters.json
Last active January 14, 2018 10:30
[Azuredeploy Parameters with visible keys] the data can be seen #acs-engine
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"agentpool1Count": {
"value": 1
},
"agentpool1Subnet": {
"value": "10.240.0.0/12"
},
@rinormaloku
rinormaloku / azuredeploy.parameters-updated.json
Created January 14, 2018 10:22
[Secure Azuredeploy Parameters template] updated to reference keyvault data #acs-engine
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"agentpool1Count": {
"value": 1
},
"agentpool1Subnet": {
"value": "10.240.0.0/12"
},
@rinormaloku
rinormaloku / SentimentController.java
Last active February 8, 2018 06:55
[Sentiment Controller in Spring WebApp] Sentiment controller that takes requests from React #spring #controller
@CrossOrigin(origins = "*")
@RestController
public class SentimentController {
@Value("${sa.logic.api.url}") // #1
private String saLogicApiUrl;
@PostMapping("/sentiment")
public SentimentDto sentimentAnalysis(@RequestBody SentenceDto sentenceDto) {
RestTemplate restTemplate = new RestTemplate();
@rinormaloku
rinormaloku / sentiment_analysis.py
Created February 8, 2018 19:51
[Python/Falsk controller] Controller that produces polarity for sentences #python #k8smastery
from textblob import TextBlob
from flask import Flask, request, jsonify
app = Flask(__name__) #1
@app.route("/analyse/sentiment", methods=['POST']) #2
def analyse_sentiment():
sentence = request.get_json()['sentence'] #3
polarity = TextBlob(sentence).sentences[0].polarity #4
@rinormaloku
rinormaloku / App.js
Created February 9, 2018 14:40
[analyzeSentence in App.js]
analyzeSentence() {
fetch('http://localhost:8080/sentiment', { // #1
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({sentence: this.textField.getValue()}) // #2
})
.then(response => response.json())
.then(data => this.setState(data)); // #3
@rinormaloku
rinormaloku / sa-frontned-pod.yaml
Last active February 10, 2018 10:43
[Frontend Pod]
apiVersion: v1
kind: Pod # 1
metadata:
name: sa-frontend # 2
spec: # 3
containers:
- image: rinormaloku/sentiment-analysis-frontend # 4
name: sa-frontend # 5
ports:
- containerPort: 80 # 6
@rinormaloku
rinormaloku / sa-frontend-pod2.yaml
Created February 10, 2018 11:42
[2nd SA Frontend pod]
apiVersion: v1
kind: Pod
metadata:
name: sa-frontend2 # Only change
spec:
containers:
- image: rinormaloku/sentiment-analysis-frontend
name: sa-frontend
ports:
- containerPort: 80
@rinormaloku
rinormaloku / service-sa-frontend-lb.yaml
Last active February 10, 2018 14:31
[SA Frontend Loadbalancer]
apiVersion: v1
kind: Service # 1
metadata:
name: sa-frontend-lb
spec:
type: LoadBalancer # 2
ports:
- port: 80 # 3
protocol: TCP # 4
targetPort: 80 # 5