Skip to content

Instantly share code, notes, and snippets.

View keyan1603's full-sized avatar

Karthikeyan Manickavasagam keyan1603

View GitHub Profile
@keyan1603
keyan1603 / SitecoreSampleUnitTest
Created November 4, 2024 09:58
Sitecore unit test sample
using AutoFixture;
using AutoFixture.AutoNSubstitute;
using AutoFixture.Xunit2;
namespace Foundation.Tests.Extensions
{
internal class AutoDbDataAttribute :AutoDataAttribute
{
public AutoDbDataAttribute()
:base(() => new Fixture()
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore role:require="Standalone or ContentDelivery or ContentManagement">
<pipelines>
<owin.initialize>
<processor type="Sitecore.Owin.Authentication.IdentityServer.Pipelines.Initialize.LogoutEndpoint, Sitecore.Owin.Authentication.IdentityServer">
<patch:delete />
</processor>
</owin.initialize>
</pipelines>
@keyan1603
keyan1603 / CreateScheduledTask.ps1
Last active September 5, 2024 19:56
Schedule App Pool recycle on specific week days docker
# Variables
$taskName = "UpdateAppPoolRecycleTimes"
$taskDescription = "Update IIS App Pool recycling times based on day of the week."
$scriptPath = "C:\Scripts\UpdateRecycleTimes.ps1" # Full path to your PowerShell script
$user = "NT AUTHORITY\SYSTEM" # User account under which the task will run
$taskRunTime = "01:00" # Time to run the task daily
# Create a daily trigger for the task at a specified time
$trigger = New-ScheduledTaskTrigger -Daily -At $taskRunTime
@keyan1603
keyan1603 / dockerfilewithScheduledAppPoolRecycleDaily
Last active September 5, 2024 19:49
Add multiple App Pool recycles at specific time of day
# Use the appropriate base image
FROM mcr.microsoft.com/windows/servercore:ltsc2019
# Copy the PowerShell script to the container
COPY set-recycle-times.ps1 /set-recycle-times.ps1
# Run the PowerShell script to set the recycle times
RUN powershell -ExecutionPolicy Bypass -File /set-recycle-times.ps1
@keyan1603
keyan1603 / SetMultipleAppPoolRecycles using config file update
Last active September 5, 2024 19:03
Set multiple App pool recycles
# Define the app pool name
$appPoolName = "DefaultAppPool"
# Clear existing schedule
Clear-WebConfiguration "/system.applicationHost/applicationPools/add[@name='$appPoolName']/recycling/periodicRestart/schedule"
# Add recycling times directly using WebConfiguration
Add-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST" `
-filter "system.applicationHost/applicationPools/add[@name='$appPoolName']/recycling/periodicRestart/schedule" `
-name "." -value @{ value = "02:00:00" }
@keyan1603
keyan1603 / preventapppoolrecycle
Last active September 5, 2024 19:33
Prevent App pool recycle in Docker environment
RUN Import-Module WebAdministration; `
Set-ItemProperty "IIS:\AppPools\DefaultAppPool" -Name Recycling.periodicRestart.time -Value 0.00:00:00; `
Set-ItemProperty "IIS:\AppPools\DefaultAppPool" -Name Recycling.periodicRestart.requests -Value 0;
@keyan1603
keyan1603 / cronautoscaler.yaml
Created June 6, 2024 11:54
Cron job for triggering the autoscaler
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: production
name: cron-runner
rules:
- apiGroups: ["autoscaling"]
resources: ["horizontalpodautoscalers"]
verbs: ["patch", "get"]
@keyan1603
keyan1603 / SitecoreSettingsList.html
Created May 19, 2024 17:29
A list of all Sitecore settings as of May 2024
<!DOCTYPE html>
<html>
<head>
<title>Sitecore Settings List</title>
<style>
#settings {
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
@keyan1603
keyan1603 / KubectlGracefulNodeRollout.txt
Last active May 16, 2024 08:22
Kubectl commands to gracefully rollout nodes in EKS
Cordon all nodes:
kubectl get nodes | ForEach-Object{($_.Split(""))[0]} | where {$_ -ne " NAME"} | ForEach-Object{(kubectl cordon $_)}
Rollout Master node:
kubectl get deployments -n kube-system| ForEach-Object{($_.Split(""))[0]} | where {$_ -ne " NAME"} | ForEach-Object{(kubectl -n kube-system rollout restart deployment $_)}
kubectl get daemonsets -n kube-system| ForEach-Object{($_.Split(""))[0]} | where {$_ -ne " NAME"} | ForEach-Object{(kubectl -n kube-system rollout restart daemonset $_)}
Rollout Worker nodes:
kubectl get deployments | ForEach-Object{($_.Split(""))[0]} | where {$_ -ne " NAME"} | ForEach-Object{(kubectl rollout restart deployment $_)}
kubectl get daemonsets | ForEach-Object{($_.Split(""))[0]} | where {$_ -ne " NAME"} | ForEach-Object{(kubectl rollout restart daemonset $_)}
@keyan1603
keyan1603 / JenkinsEKSNodeRollout
Created May 16, 2024 08:14
Jenkins script to gracefully rollout nodes when the deployment strategy is rollout deployment.
pipeline {
agent any
stages{
stage('Logging into AWS ECR'){
steps{
bat 'aws eks --region us-east-1 update-kubeconfig --name eks-cluster-name'
bat 'aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin xxxxxxxxxxx.xxx.ecr.us-east-1.amazonaws.com'
}
}